Afficher un message
Vieux 17/06/2008, 10h54   #12
Dikkie Dik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Functional difference between OR and ||

>> 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!

>
> Incorrect. Neither || nor && will evaluate the second operand if the
> first one determines the result of the expression.
>


Oops! I did not know that. I was sure I read it in the manual...

Thanks for the correction.
  Réponse avec citation
 
Page generated in 0,04738 seconds with 9 queries