PHP Data Types NULL

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

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

  1. $value = NULL;  

  2. ?>  

The following example $Var1 set to NULL and a subsequent if statement checks whether it is NULL or not.

Example :

  1. $Var1;  

  2. if ($Var==NULL)  

  3. {  

  4. echo 'Welcome to w3resource.com';  

  5. }  

  6. ?>  

Output :

Welcome to w3resource.com

View the example in browser