We have given a variable and the task is to check whether the value of given variable is null or not and returns a Boolean value using PHP. To check a variable is null or not, we use is_null() function. A variable is considered to be NULL if it does not store any value. It returns TRUE if value of variable $var is NULL, otherwise, returns FALSE.
Syntax
boolean is_null( $var )
Example:
PHP
<?php
$var1 = NULL;
$var2 = "\0" ;
$var3 = "NULL" ;
is_null ( $var1 ) ? print_r( "True\n" ) : print_r( "False\n" );
is_null ( $var2 ) ? print_r( "True\n" ) : print_r( "False\n" );
is_null ( $var3 ) ? print_r( "True\n" ) : print_r( "False\n" );
?>
|
Output:
True
False
False
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
17 Nov, 2021
Like Article
Save Article