Last active
August 29, 2015 14:13
-
-
Save dennisdegryse/286adf5aac49f1d6b066 to your computer and use it in GitHub Desktop.
Operator precedence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $x = 10; | |
| echo $x > 5 ? "1" : false ? "2" : "3"; | |
| // ================================ => = echo construct expression | |
| // + + => o1 = ternary operator at root | |
| // -------------------- => o1.x1 = first operand of o1 | |
| // + + => o1.x1.o1 = ternary operator at root of o1.x1 | |
| // ------ => o1.x1.o1.x1 = first operand of o1.x1.o1 | |
| // + => o1.x1.o1.x1.o1 = binary operator at root of o1.x1.o1.x1 | |
| // == => o1.x1.o1.x1.o1.x1 = first operand of o1.x1.o1.x1.o1 = 10 | |
| // = => o1.x1.o1.x1.o1.x2 = second operand of o1.x1.o1.x1.o1 = 5 | |
| // ====== => o1.x1.o1.x1 = first operand of o1.x1.o1 = TRUE | |
| // === => o1.x1.o1.x2 = second operand of o1.x1.o1 = "1" | |
| // ***** => o1.x1.o1.x3 = third operand of o1.x1.o1 is omitted | |
| // ==================== => o1.x1 = evaluate first operand of o1 = TRUE | |
| // === => o1.x2 = evaluate second operand of o1 = "2" | |
| // *** => o1.x3 = third operand of o1 is omitted | |
| // ================================ => = evaluate echo construct expression = "2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment