• PHP Video Tutorials

PHP - is_null() Function


Advertisements

Definition and Usage

The function is_null() checks whether the variable is null.

Syntax

bool is_null ( mixed $value )

Parameters

Sr.No Parameter & Description
1

value

The variable being evaluated.

Return Values

This function returns true if value is null, false otherwise.

Dependencies

PHP 4.0.4 and above.

Example

Following example demonstrates return values with different types of variables −

<?php
   $a = NULL;
   echo "a is "; var_dump(is_null($a)); echo "<br>";

   $b = true;
   echo "b is "; var_dump(is_null($b)); echo "<br>";

   $c = false;
   echo "c is "; var_dump(is_null($c)); echo "<br>";

   $d = 0;
   echo "d is "; var_dump(is_null($d)); echo "<br>";

   $e = 1;
   echo "e is "; var_dump(is_null($e)); echo "<br>";

   $f = '';
   echo "f is "; var_dump(is_null($f)); echo "<br>";

   $g = "\0";
   echo "g is "; var_dump(is_null($g)); echo "<br>";

   $h = "unset";
   echo "h is "; var_dump(is_null($g)); echo "<br>";
?>

Output

This will produce following result −

a is bool(true)
b is bool(false)
c is bool(false)
d is bool(false)
e is bool(false)
f is bool(false)
g is bool(false)
h is bool(false)
php_variable_handling_functions.htm

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements