PHP - is_null() Function

PHP - is_null() Function
Description:
is_null() function — Finds if a variable is NULL or not.

PHP Version: 
PHP 4 and above version.
Syntax:
is_null(variable);
is_null() function returns true when the variable is NULL, otherwise it returns false or nothing.
Return Type: Boolean

Finds if a variable is NULL or not:
<!DOCTYPE html> 
<html> 
 <body> 
  <h3>Showing result using is_null() function:</h3>
  <?php 
   $x = 0; 
   echo "x is " . is_null($x) . "<br>"; 
   $y = null; 
   echo "y is " . is_null($y) . "<br>"; 
   $z = "null"; 
   echo "z is " . is_null($z) . "<br>"; 
   $q = NULL; 
   echo "q is " . is_null($q) . "<br>"; 
  ?> 
 </body> 
</html>
Result:
Showing result using is_null() function:
x is
y is 1
z is
p is 1


EmoticonEmoticon