Generally speaking, operators have a set of priorities, which is the order in which they are executed.
Operators are also associative, that is, the execution order of operators with the same priority. This order is usually from left to right (referred to as left), right to left (referred to as right), or irrelevant.
The following table gives a brief list of operators and correlations in PHP. The rule for their appearance is that the top operator has the lowest priority. According to the order from top to bottom in the table, the priority increases.
Associativity Operator
left ,
left or
left xor
left and
right print
Left = += -= *= /= .= %= &= |= ^= ~= >=
Left ?:
Left ||
Left &&
Left |
Left ^
Left &
Left == != === !==
Left >=
Left >
Left + - .
Left * / %
Right ! - ++ == (int) (double) (string) (array) (object) @
Right []
Not relevant new
Not relevant ()
The operator with the highest precedence is: ordinary parentheses, because it can avoid the operator precedence rules.
|