Re: Re: Question about superglobals
| From: | Sam Barrow | Date: | Sat, 17 Nov 2007 04:08:32 +0000 |
| Subject: | Re: Re: Question about superglobals | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33198@lists.php.net to get a copy of this message | ||
That's a good point too, usually when globals are used at all they are
used in numerous functions It's very rare to see a variable that's used
as a global in one or two functions.
> This assumes there is never a good reason for a super global which makes
> me wonder why PHP has super globals at all then? What if, because I use
> it so often and want to differentiate it, it just works better for me to
> make it a super global? I could always name it with the standard $_
> naming scheme so as to not run into accidental use. I don't often use
> globals but when I do it's usually because it's something I'll use a
> lot. It doesn't benefit code readability to have the same thing repeated
> hundreds of times. It's not a big issue but I do like the idea of making
> super globals easy to do.
On Fri, 2007-11-16 at 20:44 -0700, Michael McGlothlin wrote:
> Stanislav Malyshev wrote:
> >> Well this is very common with PHP, it's very flexible and it's easy for
> >> a bad programmer to create chaotic code and get away with it, but this
> >> can happen with many features of PHP. For serious developers however,
> >
> > Right. This is why I don't think it's a good idea to add one more
> > feature with very high potential for abuse. Code that changes
> > behaviour of unrelated other code is usually very bad idea - think
> > about what happens if some of your functions somewhere among 10K lines
> > of code used $cfg as local variable and then you added $cfg as
> > superglobal.
> >
> >> them. No point in holding stuff back from people who could benefit from
> >> it just to protect inexperienced them from their own sloppiness. You
> >> know what I mean?
> >
> > Yes, there is a point in not implementing features that would promote
> > bad coding and unnecessary surprises for the users. Especially when
> > the same function can be achieved with existing functionality in a
> > much better way.
> This assumes there is never a good reason for a super global which makes
> me wonder why PHP has super globals at all then? What if, because I use
> it so often and want to differentiate it, it just works better for me to
> make it a super global? I could always name it with the standard $_
> naming scheme so as to not run into accidental use. I don't often use
> globals but when I do it's usually because it's something I'll use a
> lot. It doesn't benefit code readability to have the same thing repeated
> hundreds of times. It's not a big issue but I do like the idea of making
> super globals easy to do.
>
> All this forcefulness of writing pristine code from the people that
> teach people that it's okay to inline their HTML, Javascript, CSS, SQL,
> and who knows what else into their PHP? Talk about a recipe for
> disaster. Oh well, at least you didn't refuse to add a switch statement
> like Python.