+ 2
HELP! Why does this equal 2 and not 3????
<?php $a = 2; $b = $a++; echo "$b"; ?>
3 ответов
+ 9
because $b = $a++; mean use the value of a to b first then increase the value of a by 1 ,the b will become 3 if you use ++$a instead of $a++.
+ 3
I see! so
$b = $a++; = 2
and
$b = ++$a; = 3
THANKYOU!!
+ 3
$a++ is post incrementation which means the value of a is used first then incremented later so when $b=$a++ $b equals two,but in the next line a is incremented