What should be the output of echo ++$a + $a++ [duplicate]
问题 This question already has an answer here: Why is $a + ++$a == 2? 13 answers In the PHP manual, operator precedence section, there is this example: // mixing ++ and + produces undefined behavior $a = 1; echo ++$a + $a++; // may print 4 or 5 I understand the behavior is undefined because of the following reason: Since x + y = y + x the interpreter is free to evaluate x and y for addition in any order in order to optimize speed and/or memory. I concluded this after looking at the C code example