is_null
Detect whether the variable is null
is_null()
function checks whether the variable is NULL
.
If the variable is NULL
, this function returns true
(1), otherwise false
/ no return value.
Check if the variable is NULL:
<?php $a = 0 ; echo "a is " . is_null ( $a ) . "<br>" ; $b = null ; echo "b is " . is_null ( $b ) . "<br>" ; $c = "null" ; echo "c is " . is_null ( $c ) . "<br>" ; $d = NULL ; echo "d is " . is_null ( $d ) . "<br>" ; ?>
Try it yourself
The value of the variable $a is 0, not NULL, so is_null($a) returns FALSE. The values of the variables $b and $d are NULL, so both is_null($b) and is_null($d) return TRUE. The value of the variable $c is a string "null", not NULL, so is_null($c) returns FALSE.
is_null ( variable ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |