Through
Format: bool isset (mixed var [, mixed var [,...])
Function: checks whether variables are set.
Return Value:
If the variable does not exist, FALSE is returned.
If the variable exists and its value is NULL, FALSE is returned.
If the variable exists and the value is not NULL, true is returned.
When multiple variables are checked at the same time, TRUE is returned only when each individual item meets the previous requirement; otherwise, the result is FALSE.
Version: PHP 3, PHP 4, PHP 5
More instructions:
When unset () is used to release a variable, it is no longer an isset ().
The PHP function isset () can only be used for variables. Passing any other parameter will cause a parsing error.
Checks whether the defined () function has been set for constants.
- <? Php
- $ Var = '';
- If (isset ($ var) // null, 0, false
Isset determines TRUE, so
.
- Print "blank value-> isset = true .";
- $ Var = NULL; if (! Isset ($ var ))//
If the value is NULL, isset determines FALSE.
- Print "NULL value-> isset = false .";
// The following uses var_dump to output the return value of isset.
- $ A = "test ";
- $ B = "anothertest ";
- Var_dump (isset ($ a); // TRUE
- Var_dump (isset ($ a, $ B); // TRUE
- Unset ($ );
- Var_dump (isset ($ a); // FALSE
- Var_dump (isset ($ a, $ B); // FALSE
- ?>
The PHP function isset () is also suitable for checking array and object elements. If an array or object instance is not defined, false is returned for detecting the array element or object element.
- <? 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 'hello' key is NULL, so it is considered as an unset value.
- // If you want to check the NULL key value, try the following method.
- Var_dump (array_key_exists ('hello', $ a); // TRUE
- ?>
Note: because this is a language structure rather than a function, the PHP function isset () cannot be called by variable functions.