Incrementing/decrementing operators are shortcuts for += or -=, and they only work on variables.
<?php $a = 3; //from www . ja va 2 s . c o m $b = $a++; // $b is 3, $a is 4 var_dump($a, $b); $b = ++$a; // $a and $b are 5 var_dump($a, $b); ?>
The operator on the right will return first the value of $a, which is 3, assign it to $b, and only then increase $a by 1.
In the second assignment, the operator on the left first increases $a by 1, changes the value of $a to 5, and then assigns that value to $b.