You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After $x = 0;, $y = $x++; is rewritten as $y = $x + 1;, $x++;. These snippets are not equivalent. In the first snippet, $y equals 0 after which $x gets incremented, whereas in the second snippet $y becomes 1 and $x gets incremented.
You are correct, $x++ is a post increment. The old value of $x gets used for the assignment. How would you like the statement to be rewritten? Should ++$x be used to restore the described behavior or should a different example be used altogether?
Where is the problem?
What is the problem?
$x = 0;
,$y = $x++;
is rewritten as$y = $x + 1;
,$x++;
. These snippets are not equivalent. In the first snippet,$y
equals0
after which$x
gets incremented, whereas in the second snippet$y
becomes1
and$x
gets incremented.Please don't change anything below this point.
The text was updated successfully, but these errors were encountered: