Operators | Sololearn: Learn to code for FREE!

-2

Operators

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

+2

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😝😝

+1

https://www.sololearn.com/discuss/1098046/?ref=app

0

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