= 4.0.4, PHP 5, PHP 7 Parameter Description: $var: The value to be checked />



English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP is_null() function usage and example

PHP available functions

is_null() The function is used to check if 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

If the specified variable is NULL, it returns TRUE, otherwise it returns FALSE.

Online Example

<?php
$var_name = TRUE;
$var_name2 is 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:

variable var_name is not NULL
variable var_name2 is NULL

PHP available functions