lundi 6 juin 2016

Initializing a variable and using that in the if clause

if($y=3){echo $y;} and if($y=1 and $y>2){echo $y;} work as expected. However, I wonder why it's not possible to use this if($x=1 && $x>3){echo $x;} , which returns Notice: Undefined variable: x. (and operator has higher precedence than &&) If && first evaluates the right operand and after that evaluates the left hand shouldn't it work?

Aucun commentaire:

Enregistrer un commentaire