NYCPHP Meetup

NYPHP.org

[nycphp-talk] comparison with zero

Scott Mattocks scott at crisscott.com
Fri Jul 21 11:12:12 EDT 2006


Dan Cech wrote:
> Scott Mattocks wrote:
>> 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.
> 
> Actually, no.
> 
> The === operator does not do any conversion at all, the 2 arguments must
> have the same type and the same value for === to return true.

Of course I can't find the page where I read this but I know that I have 
seen many times, "=== compares the string representation of the two 
variables."

Which is why you get different results for "1" == "01" and "1" === "01".

I will keep looking for the page.
-- 
Scott Mattocks
Author of: Pro PHP-GTK
http://www.crisscott.com



More information about the talk mailing list