Post - decrement in php. | Sololearn: Learn to code for FREE!

+10

Post - decrement in php.

Can anyone explain to me why the answer is 20? $foo = 5; echo $foo * $foo--; // 20

7/23/2019 5:53:34 AM

Boboev Ahmadjon Safaralievich

3 Answers

New Answer

+1

its like 5 multiply by (5-1) //minus 1 to foo=5 bcz of the decrement -- then it will be 5 x 4.

+1

Apparently, the result varies between PHP versions according to the accepted answer in this thread. https://www.sololearn.com/Discuss/2055656/?ref=app https://code.sololearn.com/wKNpHCyYyQd2/?ref=app

0

Echo $foo(5) * $foo--( $foo is 5 bt there is -- so it will 4) (5*4)= 20