The
docs mention no guarantees for the result of such code. Here's what it seems to be doing (at this time of writing):
- ++$i increments $i and then returns an alias to $i
- $i++ returns a copy of $i and then increments $i
(++$i, ++$i) returns two
aliases to
$i, which has been incremented twice, resulting in
(2, 2).
($i++, $i++) returns two
copies of
$i, one before and one after the first post-increment, resulting in
(0, 1).