custom superglobals
| From: | Ron Korving | Date: | Sat, 06 Aug 2005 12:30:57 +0000 |
| Subject: | custom superglobals | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-17558@lists.php.net to get a copy of this message | ||
Hi,
Wouldn't it be a good feature to have users create their own superglobals? I
think it would be good for at least two reasons (rather similar though):
- Application settings can be stored in such a global, so that objects can
use them without needing the information passed to functions or using the
rather ugly "global" statement.
- A singleton constructor could use it to grab information. Normally, in my
own database abstraction layer, I would create the database object and pass
the constructor information on where to connect. I don't want to implement
my DB class to open a file to read connection information and I don't want
it to use the "global" statement. This presents a problem if I want it to be
a singleton object, because I'd need the information everytime I call
getInstance() which is of course not really an option. Personally, I don't
consider using a superglobal from within the constructor an ugly practice.
Ron