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" <[EMAIL PROTECTED]>
To: "Michael Collins" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
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
>
>
>
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to