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:

snippet
bool is_null ( mixed $var )

Parameter

Parameter Description Is compulsory
var The variable being evaluated. compulsory

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

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

Example 2

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

Example 3

snippet
<?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");
?>
PHP is_null() function
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +