PHP NULL Type
Posted on: March 16, 2010 at 12:00 AM
Advertisement
In this tutorial you will come to know about NULL values and how to make a variable NULL, how to check a variable etc.

PHP NULL type:

In PHP 4 a special type of value is introduced, which indicates that a variable does not consists of any value or NULL value. NULL is the only value of NULL datatype.

A variable is considered to be NULL if we use unset() method on a variable, or a NULL value is assigned to the variable, no value is yet assigned to it.

Two special functions are used in this context, is_null() and unset(). is_null() function is used to check whether a  variable is NULL assigned or it has some value.

PHP Null Type Example:

<?php

$a;

echo "1=True and Blank=False".is_null($a)."<br/>";

$a=23;

echo "1=True and Blank=False".is_null($a)."<br/>";

$a=NULL;

echo "1=True and Blank=False".is_null($a)."<br/>";

$a=12;

echo "1=True and Blank=False".is_null($a)."<br/>";

unset($a);

echo "1=True and Blank=False".is_null($a)."<br/>";

?>

 

Output: 

1=True and Blank=False1
1=True and Blank=False
1=True and Blank=False1
1=True and Blank=False
1=True and Blank=False1

Advertisement

Related Tags for PHP NULL Type:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 16, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com