PHP is_null() Function

❮ PHP Variable Handling Reference

Example

Check whether a variable is NULL or not:

<?php
$a = 0;
echo "a is " . is_null($a) . "<br>";

$b = null;
echo "b is " . is_null($b) . "<br>";

$c = "null";
echo "c is " . is_null($c) . "<br>";

$d = NULL;
echo "d is " . is_null($d) . "<br>";
?>
Try it Yourself »

Definition and Usage

The is_null() function checks whether a variable is NULL or not.

This function returns true (1) if the variable is NULL, otherwise it returns false/nothing.


Syntax

is_null(variable);

Parameter Values

Parameter Description
variable Required. Specifies the variable to check

Technical Details

Return Value: TRUE if variable is NULL, FALSE otherwise
Return Type: Boolean
PHP Version: 4.0.4+

❮ PHP Variable Handling Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.