Posted by Kimmo Laine on 05/25/05 22:44
"Oli Filth" <catch@olifilth.co.uk> kirjoitti
viestissδ:7R2le.34$hr1.12@newsfe1-gui.ntli.net...
> Kimmo Laine wrote:
>> $var0 = "";
>> $var1 = "bunny";
>> $default = "default";
> <...SNIP...>
>> $target = $var0 OR $var1 OR $default;
>> echo $target; //outputs bunny
>
> No it doesn't. The result is an empty string.
>
>> Why "bunny"? Seems that using or the operand is assigned into $target,
>> and if it's true, it halts. It is evaluated like this:
>>
>> (($target = $var0) || $target = $var1) || $target = $default;
>
> No it's not. The line is evaluated as:
>
> ($target = $var0) || $var1 || $default;
>
Ah... So it does, I had to test it. Well in that case the user comment at
php.net was incorrect... or I understood it wrong... :(
--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears
eternal.erectionN0@5P4Mgmail.com
Navigation:
[Reply to this message]
|