Operator priority - PHP operator priority, friends in need can refer to it.
PHP operator precedence |
Combined direction |
Operator |
Additional information |
Non-binding |
clone new |
clone and new |
Left |
[ |
array() |
Non-binding |
++ -- |
Increment/Decrease Operator |
Non-binding |
~ - (int) (float) (string) (array) (object) (bool) @ |
Type |
Non-binding |
instanceof |
Type |
Right combination |
! |
Logical operators |
Left |
* / % |
Arithmetic operators |
Left |
+ - . |
Arithmetic operators and string operators |
Left |
> |
bit operators |
Non-binding |
>= |
Comparison operators |
Non-binding |
== != === !== |
Comparison operators |
Left |
& |
bit operators and references |
Left |
^ |
bit operators |
Left |
| |
bit operators |
Left |
&& |
Logical operators |
Left |
|| |
Logical operators |
Left |
? : |
Ternary operator |
right |
= += -= *= /= .= %= &= |= ^= >= |
Assignment operator |
Left |
and |
Logical operators |
Left |
xor |
Logical operators |
Left |
or |
Logical operators |
Left |
, |
Used in many places |
This table gives Python’s operator precedence (lowest to highest). |
From lowest priority (most loosely coupled) to highest priority (most tightly coupled). |
This means that within an expression, Python will first evaluate operators listed lower in the table, and then evaluate operators listed higher in the table. |
|