PHP is_null() Function

PHP 可用的函数PHP Available Functions

is_null()The function is used to check whether a variable is NULL.

PHP Version Requirement: PHP 4 >= 4.0.4, PHP 5, PHP 7

Syntax

bool is_null ( mixed $var )

Parameter description:

  • $var: The variable to be checked.

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 'The variable var_name is NULL' . PHP_EOL; } else { echo 'The variable var_name is not NULL' . PHP_EOL; } if (is_null($var_name2)) { echo 'The variable var_name2 is NULL' . PHP_EOL; } else { echo 'The variable var_name2 is not NULL' . PHP_EOL; } ?>

The output result is:

变量 var_name 不为 NULL
变量 var_name2 为 NULL

PHP 可用的函数PHP Available Functions

Other Extensions