pr0pensity
[H]ard|Gawd
- Joined
- Sep 2, 2003
- Messages
- 1,738
$x=1;
echo $x=$x+(++$x); // prints 3, as expected
$x=1;
echo $x+=++$x; // Prints 4.
$x=1;
echo $x+=$x+=++$x; // Prints 8.
I was led to believe that x+=x and x=x+x would do the same thing. Why is the variable updated before the evaluation is complete?
echo $x=$x+(++$x); // prints 3, as expected
$x=1;
echo $x+=++$x; // Prints 4.
$x=1;
echo $x+=$x+=++$x; // Prints 8.
I was led to believe that x+=x and x=x+x would do the same thing. Why is the variable updated before the evaluation is complete?