Reply to Re: $i = $i++

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация