Re: user-defined superglobals

From: Date: Sun, 04 Jul 2004 13:08:03 +0000
Subject: Re: user-defined superglobals
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-189665@lists.php.net to get a copy of this message
Or if you wanted it to be pretty... define('MY_DATABASE_USER', 'user'); define('MY_DATABASE_PASS', 'pass'); mysql_connect('localhost',MY_DATABASE_USER,MY_DATABASE_PASS); ----- Original Message ----- From: "John W. Holmes" <holmes072000@charter.net> To: "Michael Collins" <lists@kuwago.com> Cc: <php-general@lists.php.net> Sent: Sunday, July 04, 2004 2:57 AM Subject: Re: [PHP] user-defined superglobals > 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 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > >

« previous php.general (#189665) next »