Re: superglobals
| From: | Jackson Miller | Date: | Fri, 09 Apr 2004 12:52:22 +0000 |
| Subject: | Re: superglobals | ||
| References: | 1 2 3 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-543@lists.php.net to get a copy of this message | ||
On Friday 09 April 2004 05:10, Wez Furlong wrote:
> as I recall, superglobals are resolved at script compile time, so
> a superglobal() function you can call from PHP won't be possible.
That is probably good since being able to add superglobals with a function
would probably be mis-used more times than not.
>
> You can add your own superglobals in your extension; however, since
> this isn't really going to meet the needs of others, it probably
> won't make sense to put it into PECL. (unless you have a really
> cool useful idea ;-)
So it sounds like it is possible. I have been reading the php source that I
think deals with superglobals.
I have two ways I would like to use superglobals. One way would be to provide
application variables that are accessible from multiple sessions. But that
is not what I think the coolest idea is.
The other, more important way I would like to implement a superglobal is to
implement "aspects" in the framework I am working on (http://sourceforge.net/
projects/cep). While the $_ASPECT super global will not have any value be
default, it will be a place to store object references that could be
considered "aspects" in AOP languages. These aspects would be things like
Logging, DB, Authentication, Cacheing, etc.
$_ASPECT['db'] = new DB::connect();
$_ASPECT['log'] = new Log::singleton();
$_ASPECT['auth'] = new Auth();
This provides a cleaner alternative to storing these global object references
inside an array inside the $GLOBALS array.
There may be a better way to implement aspects in PECL, but this is all I got
so far.
Thanks,
Jackson
>
> --Wez.
>
> ----- Original Message -----
> From: "Robert Cummings" <robert@interjinn.com>
> To: "Andrey Hristov" <php@hristov.com>
> Cc: "Jackson Miller" <jackson@tekzen.net>; "PHP-PECL"
> <pecl-dev@lists.php.net>; <marcus@skysaber.com>
> Sent: Friday, April 09, 2004 11:00 AM
> Subject: Re: [PECL-DEV] superglobals
>
> > On Fri, 2004-04-09 at 05:45, Andrey Hristov wrote:
> > > Jackson Miller wrote:
> > > > Please excuse me if this is not an appropriate forum for this
>
> question.
>
> > > > The short question is:
> > > > Is it possibly to create a PECL extension for PHP that adds a new
>
> (empty)
>
> > > > superglobal variable? If so, then I am assuming it would be possible
>
> to
>
> > > > create a PECL extension for adding a superglobal() method.
> > > >
> > > > I know this question has been discussed on php-dev a few times, but
>
> those
>
> > > > discussions have resulted in no solution (and I was not part of those
> > > > discussions).
> > >
> > > AFAIR it was decided that adding such a function is a bad idea.
> >
> > PECL is about special needs though, is it not? I don't see why an
> > outcome decided by internals should affect something in PECL. Is it
> > possible anyways to added a new super globals entry via an extension?