filter_has_var

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
<?

$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

filter_id

filter_input

filter_input_array

filter_list

filter_var

filter_var_array

PHP

Home Menu