NYCPHP Meetup

NYPHP.org

[nycphp-talk] comparison with zero

Scott Mattocks scott at crisscott.com
Fri Jul 21 09:20:22 EDT 2006


Michael Southwell wrote:
> All strings are evaluated as zero unless they begin with a character 
> which can be interpreted as a numeral.  You can test this as follows:

I think to be a little more clear here you have to say, "When a string 
is converted to a number, it will be converted to zero unless it begins 
with a number."

A non-empty string that is converted to a boolean will be converted to 
TRUE. Also, the === operator converts all things to strings and then 
compares the string values to see if the two are equal. Therefore, "str" 
=== 0 becomes "str" == "0" not 0 == 0.

-- 
Scott Mattocks
Author of: Pro PHP-GTK
http://www.crisscott.com



More information about the talk mailing list