Operators | Sololearn: Learn to code for FREE!



What is the value of $b? $a=2; $b=$a++; why not 3?

7/7/2018 8:50:38 PM

Sagor Sandy

3 Answers

New Answer


Because with post increment($a++) value of $a is assigned to $b. Then if you echo it out, you will see that it is 3. So it first assigns value of $a to $b and then increments it. If there was ++$a, value would be 3, because it is PRE increment meaning it is incrementing and then assigning value. Hope this helped😝😝




$а=2 $b=$a++; ????????????