+ 1
why the correct answer is 17
i think it should be 18 because the decreament after the print !!!
7 Respostas
+ 2
Because the decrement is done after the affectation of the value of $num to $num1 (post-decrement). Hence $num1 holds 18.
(Edited, I made some mistakes here.)
+ 1
Hum, no, the decrement is clearly one line before the print.
<?php
$num = 18;
$num--;
echo $num;
?>
If the decrement is done separately, whether it is pre or post doesn't matter.
0
okay but why in this the output is 18?
<?php
$num=18;
$num1=$num--;
echo $num1 ;
?>
0
got it 😀 thank you 😍
0
because in that case, is post-decrement it means that first it assigns the value(18) to num1 and then does the decrement to num. if you write:
...
echo $num1;
echo $num;
?>
it will show you 18 and 17
0
check your application, i think the app have error
let's try at playground
i was try. just search "Answer question operand"
<?php
$test=20;
$test1=$test--;
echo $test1;
?>
output is 19
0
17 is answer