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

Posted by peter on 04/12/07 06:59

> 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?

I was referring to the way it was used by the previous op. The line in the
code was $imagenum = $imagenum++; and someone advised him to use
$imagenum++; instead and in the way it was being used it did not make any
difference. If it had been used in the while statement and not in it's body
then yes it would have made a difference but in this case it did not as I
stated.

 

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

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