❮ PHP Variable Handling Reference
Check whether a variable is empty. Also check whether the variable is set/declared:
<?php
$a = 0;
// True because $a is set
if (isset($a)) {
echo "Variable 'a' is set.<br>";
}
$b = null;
// False because $b is NULL
if (isset($b)) {
echo "Variable 'b' is set.";
}
?>
Try it Yourself »
The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL.
This function returns true if the variable exists and is not NULL, otherwise it returns false.
Note: If multiple variables are supplied, then this function will return true only if all of the variables are set.
Tip: A variable can be unset with the unset() function.
isset(
variable, ....);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
... | Optional. Another variable to check |
Return Value: | TRUE if variable exists and is not NULL, FALSE otherwise |
---|---|
Return Type: | Boolean |
PHP Version: | 4.0+ |
PHP Changelog: | PHP 5.4: Non-numeric offsets of strings now returns FALSE |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!