PHP increment
$a = 3;
echo $a + +. '
';//3
echo + + $a; 5
?>
A++ is the first to add
++a is first added and then Fu
Who can tell me one step at a time, and I'll give it to him at once.
Reply to discussion (solution)
echo $a + + equals: echo $a; $a + = 1;
echo + + $a equivalent to: $a + = 1;echo $a;
In other words: $a + + is the first to use the variable value, after the self-increment
+ + $a is the first self-increment variable value, after use.
Can I make an analogy?
Other words
$a =1
Echo $a + +//meaning 1++??? equals 1
echo $++a//++1++ equals 3
Can I make an analogy?
Other words
$a =1
Echo $a + +//meaning 1++??? equals 1
echo $++a//++1++ equals 3
You finally understand is wrong, the first two steps after the execution, $a is equal to 2, so the final step is directly ++1, there will not be a + +
Look at the following example
!--? php $a = 1;echo $a + +;//output 1 output $ A before performing $a++, so the following echo $a is 2echo $a;//Output 2// 2echo + + $a;//output 3 + + $a, first perform the + + operation, that is 3, and then output $ A
echo $a + +;
equivalent to:
Echo $a;
$a = $a + 1;
Echo + + $a;
equivalent to:
$a = $a + 1;
Echo $a;
!--? php $a = 3; echo $a + +. '
'; The above sentence can be broken into echo $a,//3 output $a +1;//and then $a=4//echo + + $a; The above sentence can be split into $a +1;//first operation $a=4 plus 1 to get 5 echo $a;//5 again output?