PHP filter_has_var() 函數
定義和用法
filter_has_var() 函數檢查是否存在指定輸入類型的變量。
如果成功則返回TRUE,如果失敗則返回FALSE。
語法
filter_has_var(type, variable)
参数 | 描述 |
---|---|
type | 必需。规定要检查的类型。 可能的输入类型:
|
variable | 必需。规定要检查的变量。 |
實例
在本實例中,輸入變量"name" 被發送到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 Filter參考手冊