Checks if variable of specified type exists
Syntax
filter_has_var ( int $type , string $variable_name ) : bool
Parameters
type
One of INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.
variable_name
Name of a variable to check.
Return
Returns TRUE on success or FALSE on failure.
Examples
1 · INPUT_GET
<? // https://mydomain.com?myvariable $type = INPUT_GET; $variable_name = "myvariable"; $return = filter_has_var($type, $variable_name); var_export($return); ?>
false
2 · INPUT_POST
<? $type = INPUT_POST; $variable_name = "myvariable"; $return = filter_has_var($type, $variable_name); var_export($return); ?>
false
3 · INPUT_COOKIE
<? $type = INPUT_COOKIE; $variable_name = "myvariable"; $return = filter_has_var($type, $variable_name); var_export($return); ?>
false
4 · INPUT_SERVER
<? $type = INPUT_SERVER; $variable_name = "myvariable"; $return = filter_has_var($type, $variable_name); var_export($return); ?>
false
5 · INPUT_ENV
<? $type = INPUT_ENV; $variable_name = "myvariable"; $return = filter_has_var($type, $variable_name); var_export($return); ?>
false