Fw: [PHP] Global variables
| From: | Kevin Stone | Date: | Wed, 02 Oct 2002 20:54:23 +0000 |
| Subject: | Fw: [PHP] Global variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-118658@lists.php.net to get a copy of this message | ||
As far as I know there is no way to set a site-wide global from within a
script. Use PHP Sessions or set a Cookie and then print the variable in any
script you want by calling $_SESSION['first'] or $COOKIES['first'];. But
you'll need a starting point for your visitors in order for this to work.
If your visitors will be accessing scripts at random you can do an
include("setfirst.inc"); at the top of each script, where 'setfirst.inc'
accesses the database and sets the $first variable each time a script is
called.
-Kevin
----- Original Message -----
From: "Anna Gyor" <bali1a@freemail.hu>
To: <php-general@lists.php.net>
Sent: Wednesday, October 02, 2002 2:06 PM
Subject: [PHP] Global variables
> Hello,
>
> 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.
>
>
> Thanks!
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>