Re: [PHP] questions about $_SERVER

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12 Mar 2012 at 20:07, Tedd Sperling <tedd.sperling@xxxxxxxxx> wrote: 

> Tim:
>
> I read somewhere that using:
>
> global $x;
>
> is not recommended. Whereas, it is recommended to use:
>
> $x = $GLOBALS['x'];
> echo $x;

Tedd,

That may well be, although as I write I can't recollect having seen that anywhere; so I don't use that form. However I have been caught by something like the following:

<?php

function yes ($a)
     {
     global $x;
     if  ($a)  $x = "yes\n";
     }

first (true);

echo $x;

?>


but I haven't looked into $GLOBALS enough to know whether using them instead would have saved my bacon.

--
Cheers  --  Tim

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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux