Re: The Context of 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2007-10-02 at 12:14 -0500, Jay Blanchard wrote:
> [small rant]
> This morning's thread on strpos() brings up an interesting point, zero
> has a context.
> 
> In certain cases 0 is the equivalent of FALSE and in other cases a 0 is
> just a 0. In the context of strpos() 0 indicates that the needle is in
> the first position of the haystack. If the needle is not found in the
> haystack a Boolean FALSE is returned. In this case 0 is not the
> equivalent of FALSE.
> 
> There are other cases, most of them specific to strings, in which 0 is
> not the equivalent of FALSE. Newbies to PHP or certain functions will no
> doubt encounter these cases at some point.
> 
> Exercise care when using 0 to determine if something is FALSE and
> understand that 0 has context.
> [/small rant]

I don't know why this is a rant. In most languages 0 is equivalent to
false. Even in C when you:

#define FALSE 0

If you want to match false exactly then use the tools provided. Namely
the equality operator === and not the equivalence operator ==.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux