PHP is_null() function

PHP is_null() function

ᴰᵒᵖᵖᵉˡᵍᵃⁿᵍᵉʳ 多佩尔甘格尔


 

By using the is_null function, we can check whether the variable is NULL or not. This function was introduced in PHP 4.0.4.

 

SYNATX:

bool is_null ( mixed $var )  

 

Parameter


 

Return Type:

The PHP is_null() function returns true if var is null, otherwise false.

 

Important Note:

We can unset the variable value by using the unset function.

 

Example 1

<?php  
    $var1 = TRUE;  
    if (is_null($var1))  
        {  
            echo 'Variable is  NULL';  
        }  
        else  
        {  
            echo 'Variable is not NULL';  
        }  
?>  

 

 

Example 2

<?php  
    $x= 100;  
    unset($x);  
    echo is_null($x);  
?>  

 

 

Example 3

<?php    
    $x = NULL;   
    $y = "\0";  
    is_null($x) ? print_r("True\n") : print_r("False\n");  
    echo "<br/>";  
    is_null($y) ? print_r("True\n") : print_r("False\n");  
?>  

 

Report Page