PHP isset () function
isset () function for detecting whether a variable is set and a non-NULL.
If, after use has been unset () released a variable, then through isset () determines the return FALSE.
When using isset () test is a variable set to NULL and returns FALSE.
Also note that the null character ( "\ 0") is not equivalent to the PHP NULL constant.
PHP Version: PHP 4, PHP 5, PHP 7
grammar
bool isset ( mixed $var [, mixed $... ] )
Parameter Description:
- $ Var: variable to be detected.
If a number of parameters passed, then isset () only returns TRUE when all the parameters are set, the calculation from left to right, half-way encounter variable is not set will stop immediately.
return value
If the specified variable exists and is not NULL, then returns TRUE, otherwise returns FALSE.
<?php
$var = '';
// 结果为 TRUE,所以后边的文本将被打印出来。
if (isset($var)) {
echo "变量已设置。" . PHP_EOL;
}
// 在后边的例子中,我们将使用 var_dump 输出 isset() 的返回值。
// the return value of isset().
$a = "test";
$b = "anothertest";
var_dump(isset($a)); // TRUE
var_dump(isset($a, $b)); // TRUE
unset ($a);
var_dump(isset($a)); // FALSE
var_dump(isset($a, $b)); // FALSE
$foo = NULL;
var_dump(isset($foo)); // FALSE
?>
Article from: https://www.runoob.com/php/php-isset-function.html