Re: Re: Question about superglobals
| From: | Robert Cummings | Date: | Sat, 17 Nov 2007 06:50:01 +0000 |
| Subject: | Re: Re: Question about superglobals | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33215@lists.php.net to get a copy of this message | ||
On Sat, 2007-11-17 at 01:40 -0500, Sam Barrow wrote:
> I don't understand, people keep telling me this can cause problems so
> it's trash. Really? Functions and variables can cause problems too. Not
> to mention user input. Programming is not easy, but the more flexible it
> is the better. I think it's up to the programmer to keep track of his
> variables, rather than us limiting his functionality, just incase he
> makes a mistake.
>
> Any programmer can write bad code and it won't work. If he uses
> superglobals he should understand that he needs to document them, it's
> that simple. If that's too difficult, don't create a superglobal then,
> great.
>
> And if this isn't good enough, fine. Require an underscore for
> superglobals to differentiate them even more. I'll write the code
> myself, no problem.
This isn't the same issue as functions and classes residing in the same
global namespace. This is a problem with a single declaration affecting
variables having the same name in EVERY scoping context.
If you redefine a function --> ERROR
If you redefine a class --> ERROR
If you define a super global named $cfg -->
NO ERROR, NO WARNING, NO NOTICE
GLOBAL CLOBBERING of ALL variables names $cfg in global scope,
local function scope, class method scope.
That's one hell of a problem to track down to save a few lazy people
some keystrokes that in their naivety they think is for the greater
good.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................