Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

filter_has_var

Description

The filter_has_var of Filter for PHP checks if variable of specified type exists.

Syntax

filter_has_var(
    int $input_type,
    string $var_name
): bool

Parameters

input_type

One of INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.

var_name

Name of a variable to check.

Return

Returns true on success or false on failure.

Examples

1 · INPUT_GET

<?

// https://mydomain.com?myvariable

$input_type = INPUT_GET;
$var_name = "myvariable";

$return = filter_has_var($input_type, $var_name);

var_export($return);

?>
false

2 · INPUT_POST

<?

$input_type = INPUT_POST;
$var_name = "myvariable";

$return = filter_has_var($input_type, $var_name);

var_export($return);

?>
false
<?

$input_type = INPUT_COOKIE;
$var_name = "myvariable";

$return = filter_has_var($input_type, $var_name);

var_export($return);

?>
false

4 · INPUT_SERVER

<?

$input_type = INPUT_SERVER;
$var_name = "myvariable";

$return = filter_has_var($input_type, $var_name);

var_export($return);

?>
false

5 · INPUT_ENV

<?

$input_type = INPUT_ENV;
$var_name = "myvariable";

$return = filter_has_var($input_type, $var_name);

var_export($return);

?>
false
HomeMenu