Afficher un message
Vieux 16/06/2008, 17h47   #11
Olaf Schinkel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Functional difference between OR and ||

Daniel Klein schrieb:
> Given the functions:
>
> function first() {
> echo "first\n";
> return true;
> }
> function second() {
> echo "second\n";
> return true;
> }
>
>
> Besides operator precedence, is there any functional difference (there
> doesn't appear to be any) between:
>
> if (first() || second()) {
> echo "done\n";
> }
>
> and
>
> if (first() OR second()) {
> echo "done\n";
> }
>
> Both return:
>
> first
> done
>
>
> Daniel Klein

Both are *logical* Operators.
The differenz is the priority of them.
|| ist higher than OR. (froam high to low: &&, ||, and, or)
So if you have $a or $b || $c
you must read it like that $a or ($b || $c)

Interesting, when you mix AND, OR, &&, ||

So:
$a or $b && $c is not the same as $a || $bc and $c



  Réponse avec citation
 
Page generated in 0,06184 seconds with 9 queries