For the following code
<?php $a=1; $b=$a++; var_dump($b); $a=1; $b=$a+$a++; var_dump($b); $a=1; $b=$a+$a+$a++; var_dump($b); $a=1; $b=$a+$a+$a+$a++; var_dump($b); $a=1; $b=$a+$a+$a+$a+$a++; var_dump($b);
I got this result:
int(1) int(3) int(3) int(4) int(5)
I was expecting 1,2,3,4,5, not 1,3,3,4,5. Why after $a=1; $b=$a+$a++; $a=1; $b=$a+$a++; get $b=3 ?
PHP 7.1.5-1 + deb.sury.org ~ xenial + 1 (cli) (built: May 11, 2017 14:07:52) (NTS)
increment php opcode
Daniel Sep 05 '17 at 12:11 2017-09-05 12:11
source share