Yes, and in even larger scale applications it can become even more
useful. I have a web framework I'm working on, it's about 9,500 lines of
code now with hundreds of functions/classes. Every function/method has
to specify global for my 3 universal variables which contain large
arrays of configuration information. With this, I can say "superglobal
$mod, $sec, $cfg" in my root include file, and not worry about it again.

On Fri, 2007-11-16 at 17:23 -0700, Michael McGlothlin wrote:
> I think the superglobal keyword is a great idea. I have a custom class 
> that implements a custom interface to memcache with a MySQL backend for 
> data that drops out of memcache or is to big to be stored easily in 
> memcache. I get annoyed at needing to include a global statement in 
> every place I want to use memcache.
> > Thanks everyone, I knew this, but I didn't want to use runkit because it
> > is a beta, and i don't want all that other stuff, just superglobals.
> > Also, runkit only allows you to use php.ini, but my patch allows you to
> > specify superglobals in your script with the keyword "superglobal" by
> > saying:
> >
> > superglobal $var1, $var2 ;
> >
> > Thanks for your help though, if anyone else is interested in the patch
> > send me a message. 
> >
> > This isn't something the developers would want to implement I assume,
> > but it would be useful if they would, at a very small cost too (the
> > patch probably under 50 lines, very simple code too). If anyone would
> > like the patch to be implemented in CVS, let me know.
> >
> > On Fri, 2007-11-16 at 22:58 +0100, Johannes Schlüter wrote:
> >   
> >> Hi Sam,
> >>
> >> you could use pecl/runkit for registering your own super globals. See
> >> example 2071 on http://de3.php.net/manual/en/ref.runkit.php
> >>
> >> johannes
> >>
> >> On Fri, 2007-11-16 at 15:53 -0500, Sam Barrow wrote:
> >>     
> >>> I am trying to develop a patch for personal use to enable custom
> >>> superglobals.
> >>>
> >>> I seemed to have had it working, but am I allowed to specify
> >>> superglobals in my script, or do they have to be specified in an ini
> >>> file or statically in the PHP code? 
> >>>
> >>> I created a superglobal keyword and a function that calls
> >>> zend_register_auto_global upon the use of this keyword, but it doesn't
> >>> work. It calls zend_register_auto_global correctly and passes the
> >>> variable name and length of the variable name, but when i try to access
> >>> the variable inside a function in my PHP script, it is undefined.
> >>> However I am able to hard code my superglobal into the PHP source files
> >>> and it works.
> >>>
> >>> Is there some type of restriction on setting superglobals at runtime, or
> >>> does the structure of the PHP interpreter not allow this, or am I doing
> >>> something wrong?
> >>>
> >>> Thanks in advanced for your help.
> >>>       
> >
> >   
> 
> 
> -- 
> Michael McGlothlin
> Southwest Plumbing Supply
> 
> 

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to