+ 4
In increment and decrement operator one question is there right what is answer for that question? It's post decrement operation therefore answer should be 18 right? but it's showing as wrong when I enter 18
5 ответов
+ 3
this is because in that question u r printing that value after decrement...
in simple words we can say that once you have entered value 18 and then u decrement it and then print it..
so the value that print is the value after decrement.
0
After increment and decrement unit
0
the answer to that question is 17; that is post decrement operator. search for post decrement operator for better understanding.
0
I don't understand
- 1
maybe 2 samples will help you.
$a=1;
$b=++$a;
echo $a,$b;
this will output 2 and 2. give a the value 1 and before (preincrement) giving a's value to b, it ads 1 to it, making a,2 and b, 2.
$a=1;
$b=$a++;
echo $a,$b;
this will output 2 and 1. give a the value 1 and after (postincrement) giving a's value to b it ads 1 to it, making a, 2 and b, 1.
either way, the 'echo' comes AFTER ALL OTHER operation, including decrementing the variable; and that's why the answer to the quiz is 17.