Re: Global Variables
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: Global Variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24515@lists.php.net to get a copy of this message | ||
> Hi,I'm using PHP4 and PWS .
>
> How do I reference a global variable from another page?
> I have declared a global variable in its own page, which I reference from
> insert.php using include();
>
> $ClientExists = "NO"; /* This is a line in the application.php file
>
> include("application.php"); /* This is a line from insert.php
> echo $ClientExists; /* This is a line from insert.php.
>
> The error message is :Warning: Undefined variable:
If that is exactly your code, then it should work. I would guess that
your echo might be inside a function in which case you need to put "global
$ClientExists" at the top of the function. But if you just have:
==application.php==
$ClientExists = "NO";
==script.php==
include 'application.php';
echo $ClientExists;
then it should definitely print out "NO" for you.
-Rasmus