You are here: Re: WHILE loop problems « All PHP « IT news, forums, messages
Re: WHILE loop problems

Posted by Steve on 04/11/07 13:20

"peter" <submit@flexiwebhost.com> wrote in message
news:evi8b2$idm$1@aioe.org...
|> I think perhaps ++$imagenum would be more appropriate than $imagenum++.
| > I can't see any purpose in post-incrementing the value here.
| > But I am still a newbie to PHP.
|
| It makes absolutely no difference in the current context, it is not
getting
| assigned to anything bar iteself so the end result is the same.

it makes ALL the difference. the proof is using ++$imagenum rather than
$imagenum++. even if this were true and all there was to it, there is
incrementation involved. $imagenum after the assignment should be 1 more
than it was before the assignment! and in a loop, each pass would be 1
greater than the last. as it is, it remains the same always.

++$imagenum considers the current value of $imagenum before the
right-hand-side operation, increments, and then sets the left-hand-side
variable ($imagenum). this will return correct/expected results.

$imagenum++ considers the value of $imagenum AFTER the rhs operation,
however since $imagenum IS the lhs variable being set, it cannot be
determined to what $imagenum should be set from the rhs operation...so,
neither operation is successful. the assignment and rhs post-increment
effectively cancel eachother out.

it is not just assigning itself to itself...that would be $imagenum =
$imagenum. it is also incrementing itself after the assignment. logically,
it is:

$i = $i;
$i++;

however, it is written such that the value of $i is indeterminate...so
what's there to increment...or to what?

 

Navigation:

[Reply to this 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

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