Reply to Re: $i = $i++

Your name:

Reply:


Posted by Jerry Stuckle on 04/12/07 04:15

Andy Hassall wrote:
> On Wed, 11 Apr 2007 16:20:45 -0500, "Steve" <no.one@example.com> wrote:
>
>> 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?
>
> In C and C++ that's undefined. PHP is less formally defined and so it is even
> more daft to try it.
>
> http://c-faq.com/expr/seqpoints.html
> http://c-faq.com/expr/ieqiplusplus.html

Andy,

Actually, in both C and C++ this special case is defined. However, a
number of other cases aren't - i.e.

$i = 2;
func($i++, $i++);

could pass (2, 3), (3, 2) or even (2, 2) - depending on how the operands
are processed.

Remember - operators have precedence, but this does not generally apply
to operands. Assignment is a special case as it is always processed
last (other than the comma operator).


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[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

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