- 1

$a++

What happens if $a =2 $b=$a++ Echo $b; The answer is 2 ,how does not the value of a increases .Then why the value of "a" does not increase coz "++" shows increasing and when happened if vice versa ,for example $a=2 $b=$++a Echo $a; what is the output of both

1st Mar 2018, 6:03 PM
Akash
1 Answer
0
++a is pre-increment and a++ is post-increment. So: b=++a, first increment a then assign to b, so b=3 b=a++, b=a=2 then increment a to 3
1st Mar 2018, 6:49 PM
Sergiu Panaite
Sergiu Panaite - avatar