Afficher un message
Vieux 16/06/2008, 13h40   #5
Dikkie Dik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Functional difference between OR and ||

> There's no functional difference. Both perform a logical OR operation,
> just at different precedence levels.



There IS a functional difference: || is a "greedy" or (calculates both
inputs to determine the output, whereas the keyword or is a "lazy" or
that calculates one of the inputs and only the other one if necessary.
That is also the reason why the "or die()" construct works. If it would
always calculate both inputs, the die function would always be called!

Same applies to && and "and"

That said, I usually use "and" and "or", just for legibility. I am fully
aware of the consequences, though.
  Réponse avec citation
 
Page generated in 0,05512 seconds with 9 queries