PHP Data Types : NULL


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

$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 :

$var = NULL;

Output :


View the example in browser

Previous: Objects
Next: PHP Constants

Follow us on Facebook and Twitter for latest update.