RE: [PHP] Global variables
| From: | John W. Holmes | Date: | Wed, 02 Oct 2002 22:54:29 +0000 |
| Subject: | RE: [PHP] Global variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-118675@lists.php.net to get a copy of this message | ||
> how can I use global variables in my web portal? I have read the php
> documentation, but it works only in the same file.
> I want use more global variable on many php site.
>
> For example:
> In login.php I use the code
>
> $first=mysql_result($result,0,"FIRST_NAME");
>
> and I want to print this $first variable all of my php site.
You can't. You can, however, have a config.php or type page that's
include()'d on every page in your site where you define these variables.
For things like this that you draw from the database, it would be a good
idea to query once and add to the session.
I find it useful to use something like a $_CONF[] array.
$_CONF['user'] = 'user';
$_CONF['path'] = '/home/user/htdocs/';
etc...
---John Holmes...