> The integer 0 is equal to False, but not Null.

Not quite true.  0 evaluates to false.  They are not equal.  Try this:

if(0==false) echo "1";
if(0===false) echo "2";

You will find that this only prints "1".  0 and false are distinct and 
separate values.  This is something that confuses a lot of people, 
especially in conjunction with something like the strpos() function which 
will return 0 when it matches something at position 0 in the string, but 
it returns false when there is no match.  A lot of people will mistakenly 
do:

  if(strpos("abcdef","abc")) { ... }

and then be confused that the condition appeared not to be met.  What they 
actually should have done was:

  if(strpos("abcdef","abc")!==false) { ... }

So be careful and try to think of 0 and false as distinct and separate 
entities and you will avoid coding mistakes like this.

-Rasmus

 > > Robin
> 
> Kodrik wrote:
> > 
> > > > If you set $qty=0; then $qty has no value.
> > >
> > > Of course it has a value.
> > 
> > No it doesn't have a value.
> > PHP interprets 0 as null.
> > 
> > A very easy way for you to check:
> > 
> > $value=0;
> > 
> > if(!$value) printf("$value doesn't have a value (it didn't even print
> > 0)<br>\n");
> > 
> > $value="0"
> > if($value) printf("$value does have a value if I put "0" instead of 0<br>\n");
> > 
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to