isset
Detect whether the variable is set and is not null
isset()
function checks if the variable is set, which means that the variable must be declared and not NULL
.
If the variable exists and is not NULL
, the function returns true
, otherwise false
.
Note: If multiple variables are provided, this function returns true
only if all variables are set.
Tip: You can use unset()
function to unset variables.
Check if the variable is empty. Also check if 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
isset ( variable , ... . ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |
... | Optional. Another variable to check. |