04-15-2009, 09:06 PM
|
#3 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
For that use, you would need to use a pre-increment rather than post-increment operator. With your original code, using a post-increment, the expression $test++ evaluates to 1 (this is used for the assignment) then the value is incremented. With a pre-increment, the expression ++$test evaluates to 2 which is used in the assignment to $test2
Full details: http://php.net/operators.increment
P.S. xenon beat me to it, both posts say the same thing.
|
|
|
|