filter_has_var() function is used to check whether a variable of the specified type exists.
filter_has_var(type, var)
#type − There are five input types to check, namely INPUT_GET, INPUT_POST, INPUT_COOKIE , INPUT_SERVER or INPUT_ENV.
var − The name of the variable.
The filter_has_var() function returns true on success and false on failure.
The following is an example to quickly check the input variable "email". This example uses the value of INPUT_GET.
Demo
<?php if (!filter_has_var(INPUT_GET, "email")) { echo("Email isn't there!"); } else { echo("Email is there!"); } ?>
The following is the output result.
Email isn't there!
The above is the detailed content of filter_has_var() function in PHP. For more information, please follow other related articles on the PHP Chinese website!