[nycphp-talk] What's going on here? PHP conditional.
John Lacey
jlacey at att.net
Fri Jul 2 11:29:35 EDT 2004
Aaron Fischer wrote:
> From the NYPHP Phundamentals site, I think this may help answer your
> question:
> http://phundamentals.nyphp.org/PH_variableevaluation.php?expiredate=10/
> 10/2003
>
> -Aaron
>
> On Jul 2, 2004, at 11:18 AM, Brian Kaney wrote:
>
>> Does anyone know why (0 == 'string') evaluates to true?
>>
>> According to the manual, the integer 0 converts to FALSE. A non-empty
>> (or non-zero) string is considered TRUE. I would think if (FALSE ==
>> TRUE) should be evaluated as false?
>>
>> http://us2.php.net/manual/en/
>> language.types.boolean.php#language.types.boolean.casting
>>
I believe it's because the 0 is being cast internally to a string value
since it's being compared against a string. So, a 0 int is a '30' ASCII
string value and therefore TRUE since it's now a non-zero
John
More information about the talk
mailing list