Re: nested, referenced foreach & implicit current array pointer issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



speedy wrote:
> Hello Jochem,
> 
> Wednesday, January 31, 2007, 7:41:42 PM, you wrote:
> 
>> use of 'global' is bad practice in anything that resembles a complex/real
>> application. your function has no control over the what $arr is and any piece of
>> code code change $arr into *anything* at any time.
> 
>> instead I would suggest that your better off doing one of 2 things:
> 
>> bad advice? I'm open to being corrected :-)
> 
> I wondered privately if anyone would give that very useful advice. O:)
> It is similar to what I told a colleague who wrote the code which
> triggered the bug. :) 

lol :-)

(side-note: I was kinda sympathetic to what he did - he
> was cutting corners in a relatively small, stand-alone project :p)

besides that, it's annoying to run into weird behaviour when you (he)
has been consiencious with regard to what was being coded.

ce la vie.

> 
> Be what may be, the hard-to-debug side-effect stands as weak point
> of PHP design no less.

I'll take you word on in :-) like I said I got a bit lost in your explaination -
if nothing else it teaches me to pay even closer attention whenever I use
references.

AFAIK, as far as scalars in php are concerned, references don't buy you anything
in terms of performance if your *not* intending on changing the copied variable because
of the 'copy-on-change' strategy php uses internally.

> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux