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

INPUT_GET

<?

// https://mydomain.com?myvariable

$type = INPUT_GET;
$variable_name = "myvariable";

$return = filter_has_var($type, $variable_name);

var_export($return);

?>
false

INPUT_POST

<?

$type = INPUT_POST;
$variable_name = "myvariable";

$return = filter_has_var($type, $variable_name);

var_export($return);

?>
false

INPUT_COOKIE

<?

$type = INPUT_COOKIE;
$variable_name = "myvariable";

$return = filter_has_var($type, $variable_name);

var_export($return);

?>
false

INPUT_SERVER

<?

$type = INPUT_SERVER;
$variable_name = "myvariable";

$return = filter_has_var($type, $variable_name);

var_export($return);

?>
false

INPUT_ENV

<?

$type = INPUT_ENV;
$variable_name = "myvariable";

$return = filter_has_var($type, $variable_name);

var_export($return);

?>
false

PHP

Home Menu