Posted by Steve on 04/12/07 14:18
"Steve" <no.one@example.com> wrote in message
news:JgcTh.1016$AE5.731@newsfe06.lga...
| someone asked a question in alt.php about a problem they were having with
an
| algorytm. it contained something to the effect of:
|
| $i = $i++;
|
| some example code they'd snatched somewhere. in a loop, the expected $i to
| increment. i explained why i thought it would not - as it does not.
however,
| i want to make sure i gave a valid answer.
|
| anyone have input?
thanks all. that's how i explained it. i didn't quite get why the value of
$i remained the same (whatever it's initial value was)...until:
$i is incremented. Then $i is set with the old (pre-increment) value of
$i (++ has precedence over =).
thanks jerry. it just snapped for me. it's that even though $i++ may
increment, the lhs assignment is made from $i's initial value prior to the
increment... it's the = that resets/nullifies the ++ in this case. that
about right?
[Back to original message]
|