Operators, precedence, and their associativity
Operators Associativity
, Left "$x, $y, $z" is "($x, $y), $z"
or Left "$x OR $y OR $z" is "($x OR $y) OR $z"
xor left "x XOR y XOR z" is "($x XOR $y) XOR $z"
and Left "x AND y AND z" is "(x AND y) AND z"
= += -= * = /= .= %= &= |= ^= <<= gt;>= Right "$x /= $y /= $z" is "$x /= ($y /= $z)"
? : Left
|| Left "$x || $y || $z" is "($x || $y) || $z"
&& Left "$x && $y && $z" is "($x && $y) && $z"
| Left "$x | $y | $z" is "($x | $y) | $z"
^ Left "$x ^ $y ^ $z" is "($x ^ $y) ^ $z"
& Left "$x & $y & $z" is "($x & $y) & $z"
== != === !== Non-associative
< < = > >= Non-associative
<< >> Left "$x >> $y >> $z" is "($x >> $y) >> $z"
+ - . Left "$x - $y - $z" is "($x - $y) - $z"
* / % Left "$x / $y / $z" is "($x / $y) / $z"
! ~ ++ -- (int) (float) (string)(array) (object) @ Right
[ Right
new Non-associative
Related examples in the same category