+ 2

help

Какой результат получается из следующего кода? <? php $ num = 18; $ num--; echo $ num; ?>

1st Mar 2018, 10:35 PM
Vladislav Rimashevsky
Vladislav Rimashevsky - avatar
1 Answer
+ 3
$num = 18; $num--; echo $num; The result will be 17. The post decrement operator will minus 1 from the $num variable and leave the value of 17. It should also be noted that in other cases when using the post decrement, the original value of $num will be used and after it is used then 1 will be subtracted from it, as opposed to the pre decrement ( --$num) which will subtract 1 first and then use that value in calculations etc.
2nd Mar 2018, 12:18 AM
Tarantino
Tarantino - avatar