You are here: Re: Whats the diffecence between '&' and '&&' operators? « PHP Language « IT news, forums, messages
Re: Whats the diffecence between '&' and '&&' operators?

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]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация