|
Posted by Michael Fesser on 09/04/07 17:33
..oO(The Natural Philosopher)
>Michael Fesser wrote:
>>
>> The second statement simply means that the value of $int, whatever it
>> may be, evaluates to FALSE.
>>
>but what is "false", in this context?
The result after the type cast?
>Null length string? string
>containing "0" Magic value?
If you write
if ($int) {...}
then there's no other way for PHP than to cast the $int variable to a
boolean, because that's what the 'if' statement expects. The manual
explains in detail how this type casting works and which values evaluate
to FALSE:
Converting to boolean
http://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
If you don't want that, then you should not rely on the automatic type
juggling, but better explain to PHP what you actually want to test for:
if ($int != 0) {...}
Micha
Navigation:
[Reply to this message]
|