The isset() function in PHP is used to detect whether a variable has been set and is not NULL.
If a variable has been released using unset(), it will return FALSE through isset().
If isset() is used to test a variable that is set to NULL, FALSE will be returned.
Also note that the null character ("\0") is not equivalent to PHP's NULL constant.
PHP version requirements: PHP 4, PHP 5, PHP 7
The syntax is
bool isset ( mixed $var [, mixed $... ] )
Parameter description:
$var: to be detected Variables.
If multiple parameters are passed in at one time, isset() will only return TRUE when all parameters are set. The calculation process is from left to right and will stop immediately when an unset variable is encountered.
Return value
If the specified variable exists and is not NULL, TRUE is returned, otherwise FALSE is returned.
Example
<?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 ?>
The output result is
变量已设置。 bool(true) bool(true) bool(false) bool(false) bool(false)
The above is the detailed content of What does isset in php mean?. For more information, please follow other related articles on the PHP Chinese website!