Re: user-defined superglobals

From: Date: Sun, 04 Jul 2004 06:57:06 +0000
Subject: Re: user-defined superglobals
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-189659@lists.php.net to get a copy of this message
Michael Collins wrote:
I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP.
You can do the same thing with a PHP file and have it auto_prepended to your scripts or just include() it yourself. You can't make your own superglobals, but you can assign keys to the existing ones, if you really want. $_SERVER['MY_DATABASE_USER'] = 'user'; $_SERVER['MY_DATABASE_PASS'] = 'pass'; mysql_connect('localhost',$_SERVER['MY_DATABASE_USER'],$_SERVER['MY_DATABASE_PASS']); etc... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#189659) next »