The difference between ++i and i++
1, the use of ++i (take A=++i, i=2 as an example)
The I value is first added to 1 (that is, i=i+1) and then assigned to the variable a (that is, a=i),
Then the final a value is equal to 3, and the I value equals 3.
So a=++i equivalent to i=i+1, a=i
2, the use of i++ (take a=i++, i=2 as an example)
First assign the I value to the variable a (that is, a=i), then I value 1 (that is, i=i+1),
Then the final a value is equal to 2, and the I value equals 3.
So a=i++ equivalent to A=i, i=i+1
3, ++i and i++
A=++i equivalent to i++, a=i
a=i++ equivalent to A=i, i++
4, ++i and i++ when used alone, equivalent to I=i+1
If you assign a new variable, the ++i first assigns the I value to 1 and the i++ first to the new variable.
http://www.bkjia.com/PHPjc/1133573.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133573.html techarticle the difference between ++i and i++, difference 1, ++i usage (take a=++i, i=2 for example) first add the I value 1 (that is, i=i+1), and then assign to the variable a (that is, a=i), then the final a value, etc. ..