What is NULL in PHP?
NULL is a special data type in PHP that has only one value, NULL. It means “no value”. NULL is not same as 0, empty string or false.
A variable is NULL in three cases: when you assign NULL to it, when it was never created, or when you remove it with unset().
<?php
$x = "Hello PHP!";
$x = null;
var_dump($x);
var_dump(is_null($x));
var_dump(isset($x));
?>
Output:
Tutorials Class - Output Window
NULL
bool(true)
bool(false)
To check for NULL use is_null() or === null. The isset() function returns false for a NULL variable.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |