Re: questions about $_SERVER
| From: | Tedd Sperling | Date: | Mon, 12 Mar 2012 20:07:42 +0000 |
| Subject: | Re: questions about $_SERVER | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316997@lists.php.net to get a copy of this message | ||
On Mar 11, 2012, at 3:04 PM, Tim Streater wrote:
>
> In the following, $x is a global but not a super-global (AFAIK).
>
>
> <?php
>
> function echox ()
> {
>
> global $x;
>
> echo $x;
>
> }
>
> $x = "Hello world\n";
>
> echox ();
>
> ?>
>
> --
> Cheers -- Tim
Tim:
I read somewhere that using:
global $x;
is not recommended. Whereas, it is recommended to use:
$x = $GLOBALS['x'];
echo $x;
In any event, what I found interesting is:
print_r($GLOBALS)
if will list all the variables (plus more) in your script. Thus, all variables in your main script
are also included in the $GLOBALS array.
Cheers,
tedd
_____________________
tedd.sperling@gmail.com
http://sperling.com