PHP filter_has_var () ฟังก์ชัน
ความหมายและการใช้งาน
filter_has_var () ฟังก์ชั่นการตรวจสอบว่าการป้อนข้อมูลที่ระบุชนิดตัวแปรที่มีอยู่
หากประสบความสำเร็จก็จะส่งกลับจริงในความล้มเหลวกลับ FALSE
ไวยากรณ์
filter_has_var(type, variable)
参数 | 描述 |
---|---|
type | 必需。规定要检查的类型。 可能的输入类型:
|
variable | 必需。规定要检查的变量。 |
ตัวอย่าง
ในตัวอย่างนี้ใส่ตัวแปร "ชื่อ" ที่ถูกส่งไปยังหน้าของ PHP:
<?php
if(!filter_has_var(INPUT_GET, "name"))
{
echo("Input type does not exist");
}
else
{
echo("Input type exists");
}
?>
if(!filter_has_var(INPUT_GET, "name"))
{
echo("Input type does not exist");
}
else
{
echo("Input type exists");
}
?>
รหัสการส่งออกจะเป็นดังนี้:
Input type exists
อ้างอิงกรองสมบูรณ์ PHP