Page 1 of 1

Is integer zero null?

Posted: Wed Dec 31, 2008 3:45 am
by incubator136
Hi,
I wondered by checking the output of the following php script.

Code: Select all

 
<?php
$test = 0;
if($test != '')
    echo  ' Not Null';
else
    echo  ' Null';
?>
 
Instead of "Not Null" as I expected, I got the output as "Null".
The script works if I use any value except 0 or if I use quotes around 0.
The integer 0 is considered as null unlike other integers.
I am bit confused, can anyone help me out?
Thanks in advance …

Re: Is integer zero null?

Posted: Wed Dec 31, 2008 4:02 am
by requinix

Re: Is integer zero null?

Posted: Wed Dec 31, 2008 4:31 am
by incubator136
Thanks tasairis!