Through this example i think you can better understand
if ( !filter_has_var(INPUT_GET, 'email') ) {
echo "Email Not Found";
}else{
echo "Email Found";
}
Output
localhost/nanhe/test.php?email=1 //Email Found
localhost/nanhe/test.php?email //Email Found
http://localhost/nanhe/test.php //Email Not Found
Consider on second example
http://localhost/nanhe/test.php
$_GET['email']="info@nanhe.in";
if ( !filter_has_var(INPUT_GET, 'email') ) {
echo "Email Not Found";
}else{
echo "Email Found";
}
But output will be Email Not Found
filter_has_var
(PHP 5 >= 5.2.0)
filter_has_var — Vérifie si une variable d'un type spécifique existe
Description
bool filter_has_var
( int
$type
, string $variable_name
)Liste de paramètres
-
type -
Une constante parmi
INPUT_GET,INPUT_POST,INPUT_COOKIE,INPUT_SERVERouINPUT_ENV. -
variable_name -
Nom de la variable à vérifier.
Valeurs de retour
Cette fonction retourne TRUE en cas de
succès ou FALSE si une erreur survient.
nanhe dot kumar at gmail dot com ¶
2 months ago
drm at melp dot nl ¶
4 years ago
Please note that the function does not check the live array, it actually checks the content received by php:
<?php
$_GET['test'] = 1;
echo filter_has_var(INPUT_GET, 'test') ? 'Yes' : 'No';
?>
would say "No", unless the parameter was actually in the querystring.
Also, if the input var is empty, it will say Yes.
