Current Location: Home> Function Categories> is_null

is_null

Detect whether the variable is null
Name:is_null
Category:Variable processing
Programming Language:php
One-line Description:Check whether the variable is NULL.

Definition and usage

is_null() function checks whether the variable is NULL .

If the variable is NULL , this function returns true (1), otherwise false / no return value.

Example

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

Example explanation:

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.

grammar

 is_null ( variable ) ;
parameter describe
variable Required. Specifies the variable to check.
Similar Functions