Update page 'P# v1.0 Specification'
@@ -288,29 +288,29 @@ The order of evaluation of operators in an expression is determined by the prece
|
|||||||
### 6.1. Operator Precedence
|
### 6.1. Operator Precedence
|
||||||
When an expression contains multiple operators, the precedence of the operators controls the order in which the individual operators are evaluated. The precedence of an operator is established by the definition of its associated grammar production. The following list shows common PHP operators ordered by precedence (highest precedence first):
|
When an expression contains multiple operators, the precedence of the operators controls the order in which the individual operators are evaluated. The precedence of an operator is established by the definition of its associated grammar production. The following list shows common PHP operators ordered by precedence (highest precedence first):
|
||||||
|
|
||||||
| Description | Operator | Associativity |
|
| Precedence | Description | Operator | Associativity |
|
||||||
|---------------------|-------------|---------------|
|
|------------|-----------------------|------------------|-------------------|
|
||||||
| increment/decrement | ++ -- | left |
|
| 1 | object-related | clone new | non-associative |
|
||||||
|
| 2 | postfix operators | -> :: [ | left-associative |
|
||||||
|
| 3 | increment / decrement | ++ -- | non-associative |
|
||||||
* increment/decrement (++ --)
|
| 4 | unary operators | - + ~ ! @ | right-associative |
|
||||||
* casting
|
| 4 | cast operators | (typedef) | right-associative |
|
||||||
* logical "not" (!)
|
| 7 | binary operators | instanceof | non-associative |
|
||||||
* bitwise "not" (~)
|
| 7 | arithmetic operators | * / % | left-associative |
|
||||||
* arithmetic (* / %)
|
| 8 | arithmetic operators | + - | left-associative |
|
||||||
* arithmetic and string (+ -)
|
| 9 | bitwise operators | << >> | left-associative |
|
||||||
* bitwise (<< >>)
|
| 10 | comparison | < <= > >= | non-associative |
|
||||||
* comparison (< <= > >= <>)
|
| 11 | comparison | == != === !== | non-associative |
|
||||||
* comparison (== != === !==)
|
| 12 | bitwise and | & | left-associative |
|
||||||
* bitwise "and" (&)
|
| 12 | reference operator | =& | left-associative |
|
||||||
* bitwise "xor" (^)
|
| 13 | bitwise xor | ^ | left-associative |
|
||||||
* bitwise "or" (|)
|
| 14 | bitwise or | \| | left-associative |
|
||||||
* logical "and" (&&)
|
| 15 | logical and | && | left-associative |
|
||||||
* logical "xor" (^^)
|
| 16 | logical xor | ^^ | left-associative |
|
||||||
* logical "or" (||)
|
| 17 | logical or | \|\| | left-associative |
|
||||||
* ternary operator (? :)
|
| 18 | ternary operator | ? | left-associative |
|
||||||
* assignment (= += -= *= /= .= %=)
|
| 19 | assignment operators | = += -= *= /= %= | right-associative |
|
||||||
* comma operator (,)
|
| 23 | comma operator | , | left-associative |
|
||||||
|
|
||||||
### 6.2. Associativity Rule
|
### 6.2. Associativity Rule
|
||||||
Sometimes the precedence is not satisfactory to determine the outcome of an expression. There is another rule called associativity. The associativity of operators determines the order of evaluation of operators with the same precedence level.
|
Sometimes the precedence is not satisfactory to determine the outcome of an expression. There is another rule called associativity. The associativity of operators determines the order of evaluation of operators with the same precedence level.
|
||||||
|
|||||||
Reference in New Issue
Block a user