The is_null() function is used to detect whether a variable is NULL.
PHP version requirements: PHP 4 >= 4.0.4, PHP 5, PHP 7
grammar
bool is_null (mixed $var)
Parameter description:
$var: The variable to be tested.
return value
Returns TRUE if the specified variable is NULL, otherwise returns FALSE.
Example
Example
<?php $var_name = TRUE ; $var_name2 = NULL ; if ( is_null ( $var_name ) ) { echo ' Variable var_name is NULL ' . PHP_EOL ; } else { echo ' Variable var_name is not NULL ' . PHP_EOL ; } if ( is_null ( $var_name2 ) ) { echo ' Variable var_name2 is NULL ' . PHP_EOL ; } else { echo ' Variable var_name2 is not NULL ' . PHP_EOL ; } ?> The output is:
The variable var_name is not NULL and the variable var_name2 is NULL.