w3resource

PHP Data Types : NULL

Description

The special NULL value represents a variable has no value (nonvalue or unvalue). It is similar to Python's" None" or Perl's "undef".

NULL is the only possible value of type NULL.

It identifies variables being empty or not and useful to differentiate between the empty string and null values of databases.

There is only one value of type NULL, and that is the case-insensitive keyword NULL.

The following is an example of using NULL.

Syntax to define php null type

<?php
$value = NULL;
?>

In the following example, $var set to NULL and using var_dump and is_null it is shwon that the value of $var is NULL.

Example :

<?php
$var = NULL;
var_dump(is_null($var));
?>

Output :

bool(true)

View the example in browser

Previous: Objects
Next: PHP Constants



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/data-types/NULL.php