|
Posted by Tyno Gendo on 04/11/07 22:57
Gordon Burditt wrote:
>> Yes, definately a syntax to avoid, seems unpredictable at best...
>>
>> <?php
>> $i = 2;
>> echo $i++ + 1; /// i'd expect 4, gives 3, ignores ++ increment
>
> Please get your expecter fixed. $i++ returns the value *BEFORE*
> the increment. (If you want ++$i, you know where to find it.) This
> one is unambiguous since all possible orders come up with the same
> result.
>
> For the other expressions involving $i++ and another reference to $i's
> value to give a resource returning Donald Trump, who's going to find the
> programmer and say "You're Fired".
>
Yes i can see that, and I'd ever use this crazy syntax anyway, but the
"human" way of reading this would seem to make it make sense so you can
understand how easy it is to be misinterpreted.
to the average bod....
$i++ would say 2+1 which is 3 (shock), yes... + 1, yep, 4, ERM... NO.
crazy computers, they do the most crazy things ;)
[Back to original message]
|