Re: questions about $_SERVER

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

 



On Mar 12, 2012, at 7:12 PM, Tim Streater wrote:
> <?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.

I'm not sure what would have saved bacon in the above case. I don't see how your example would work. I think it contained a typo.

In what I think you were trying to demonstrate, I would just pass $x by reference (&$x) -- or -- return $x by value. I would not have used a global,

In any event, I seldom use globals anyway. This was more an academic discussion.

Cheers,

tedd

_____________________
tedd.sperling@xxxxxxxxx
http://sperling.com
-- 
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