|
Posted by Steve on 04/12/07 14:58
| > 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?
|
| Yes. That's why the assignment is not used with $i++. $i++ is a
| shorthand that both increments and assigns at the same time. If you go
| and add another assignment then it's fucked.
|
| $i = ++$i; // this would've worked as expected, though.
|
| Maybe this helps:
no, no...i got it. not only did i explain it correctly in alt.php but gave
examples - even explaining that $i = ++$i *would* give expected results. i
was just trying to do it all in my head and match it up with each example's
results. i'm there now.
thx,
me
Navigation:
[Reply to this message]
|