What should be the output of echo ++$a + $a++ [duplicate]
This question already has answers 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 in this article . My question is that the output of the above mentioned PHP code should be 4 no