Reply to Re: Does passing an uninitialized array variable initialize it? (PHP 5)

Your name:

Reply:


Posted by Rik on 07/31/07 00:46

On Tue, 31 Jul 2007 02:38:04 +0200, Jerry Stuckle =

<jstucklex@attglobal.net> wrote:
> I take this back - the result of the operation is unpredictable. That=
's =

> because:
>
> $rank[$i] =3D trim($rank[$i++]);
>
> $rank[$i++]
>
> is evaluated as $rank[$i]. However, when
>
> $rank[$i]
>
> is evaluated, does it use the old or the new version of $i?

This is indeed dubious. Which of the '[' gets evaluated first? Allthough=
, =

left-associtivity might indicate the first one should be evaluated first=
=

(PHP4 behaviour).

However, for:

$array[$i] =3D $i++;

Precedence as defined should kick in clearly. The '[' isn't in the table=
=

just for show.

> The bottom line: don't change a value and use it in the same statement=
.. =

> Results are unpredictable.

And makes for more readable code indeed. However, if I read the =

documentation I fully expect the PHP4 result from my example, not the PH=
P5 =

one...
-- =

Rik Wasmus

[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

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