A little more supplementary info. When a PHP script is "lexed", i.e. when it is scanned, the tokens comprising the script are examined. A pair of characters like "++" signify an increment token, as follows:
<ST_IN_SCRIPTING>"++" {
RETURN_TOKEN(T_INC);
}
This "rule" is in the file Zend/language_scanner.l which accompanies PHP when you download and install it. The only way that a script when scanned becomes intelligible to the lexer with regards to pre- or post-incrementing variables is if there is some kind of demarcation such as spacing so that each "+" is properly evaluated in context.
Note that writing code like the following is inadvisable:
<?php
$x=0;
echo $x++ + ++$x;
even tho' it will be lexed correctly. The reason for objecting to this coding style is because it can be less than apparent to human brains as to what is really occurring. The order of evaluation is not what it may seem, i.e. a variable being post-incremented and then being added to itself with its pre-incremented value.
Per the opcodes, the pre- and post-incrementations occur before addition takes place. Also, note that post-incrementation returns a variable's value and then increments it. So, initially, $x is assigned a value of 0. Then, it is post-incremented so that a temporary variable returns with a value of zero. Then, $x gets incremented to acquire a value of one. Next, $x is pre-incremented, and so $x moves from a value of one to two and its temporary variable evaluates as two. Lastly, the the two temporary variables are added, so that 0 + 2 == 2
; see here as well as here.
Also, an excellent read here.
Incidentally, in this case PHP conforms with its forbear The C Programming Language; see here.