0
$num=12; $num-- ; echo $num;
it should decrease value or num but first display the original value of num that is 12 is that so or decrement operater always first decrease then display , either it is pre-decrement or post-decrement
4 Antworten
+ 7
$num = 12;
echo $num--;
outputs 12 because in post decrement, value is returned and then decrement is done.
$num = 12;
echo --$num;
outputs 11 because in pre decrement, decrement is done and then value is returned.
+ 7
$num = 12;
$num--;
echo $num;
Line 1 : Value of $num is 12.
Line 2 : Value of $num becomes 11.
Line 3 : Value of $num i.e. 11 is printed.
In my previous post, I explained how pre decrement and post decrement work.
0
but a code in learning pages
ans is given to 11
0
then whats the difference in $num-- and --$num ?
both are doing same work