+ 10

Post - decrement in php.

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

23rd Jul 2019, 5:53 AM
Boboev Ahmadjon Safaralievich
Boboev Ahmadjon Safaralievich - avatar
3 Réponses
+ 1
its like 5 multiply by (5-1) //minus 1 to foo=5 bcz of the decrement -- then it will be 5 x 4.
24th Jul 2019, 3:37 PM
Mark Aerol Tomarse
Mark Aerol Tomarse - avatar
+ 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
5th Sep 2021, 4:13 PM
silentlearner
silentlearner - avatar
0
Echo $foo(5) * $foo--( $foo is 5 bt there is -- so it will 4) (5*4)= 20
31st Jul 2019, 8:39 AM
Shwetali Talele