Through the
Format: bool Isset (mixed var [, mixed Var [, ...])
Function: Detect whether the variable is set
return value:
Returns FALSE if the variable does not exist
Returns FALSE if the variable exists and its value is null
Returns TURE if the variable exists and the value is not NULL
Returns TRUE if each item meets the previous requirement when checking multiple variables at the same time, otherwise the result is FALSE
Version: PHP 3, PHP 4, PHP 5
More information:
After you use Unset () to release a variable, it will no longer be isset ().
PHP functions Isset () can only be used for variables, and passing any other parameter will result in parsing errors.
Detects if a constant is set to use the defined () function.
- < ? PHP
- $ var = '' ;
- if (Isset ($var))//null value, 0, False
The assignment result is isset to TRUE, so behind
The text will be printed out.
- print "Blank value- > isset = true. ";
- $ var = NULL ; if (!isset ($var))//
Null will be isset sentenced to FALSE
- print "NULL value- > isset = false. ";
The following uses the return value of the Var_dump output 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
- ?>
The PHP function Isset () also applies to the checking of array elements and object elements. If an array or object instance is not defined, the array element/object element detected in it will be returned false.
- < ? PHP
- $ a Array (' Test ' => 1, ' hello ' => NULL);
- Var_dump (isset ($a [' Test ']); TRUE
- Var_dump (isset ($a [' foo ']); FALSE
- Var_dump (isset ($a [' hello ']); FALSE
- The value of the key ' hello ' is equal to NULL, so it is considered to be an unassigned value.
- If you want to detect NULL key values, you can try the methods below.
- Var_dump (array_key_exists (' hello ', $a)); TRUE
- ?>
Note: Since this is a language structure and not a function, PHP function isset () cannot be called by a variable function.
http://www.bkjia.com/PHPjc/445983.html www.bkjia.com true http://www.bkjia.com/PHPjc/445983.html techarticle by the format: bool Isset (mixed var [, mixed Var [, ...]) function: Detects if the variable has a return value: If the variable does not exist, it returns FALSE if the variable exists and its value is NULL, also ...