View Single Post
Old 04-15-2009, 09:06 PM   #3 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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.
Salathe is offline  
Reply With Quote