Re: Opinion about the using $GLOBALS directly
| From: | Sancar Saran | Date: | Wed, 19 Dec 2007 14:18:07 +0000 |
| Subject: | Re: Opinion about the using $GLOBALS directly | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-266074@lists.php.net to get a copy of this message | ||
Hello Jochem,
Thanks for response, I'm using this aproach maybe more than one year. I did
not get any problems.
>
> there is no real difference between 'global $foo' and $GLOBALS['foo'],
> and the second is probably more maintainance friendly (as Rob pionted out)
Yes you are right writing global $foo in 25+ functions a bit problematic.
> that said, avoid globals like the plague - sometimes you may come up with
> a situation where using a global is really necessary - such situations
> should be the exception rather than the rule, often if your thinking of
> using a global there is another way of doing it. jmho
And this is why I'm asking here, WHY I should avoid globals like plague ?
Every one says bad. Alright, but no one says WHY ?
I try to use alternative ways. But maintenance, complexty and speed costs much
too high.
I did not see any benefit.
Robert Cummings says to "you may confusing to setting variable". I have some
debugging methots to detect this.
And Of course I did not use someting like for($GLOBALS['i']=0;....
And I use GLOBALS for everything for I need someting more than once. (Db
pointer or config array etc).
Thanks for response
Regards
Sancar