Re: [PHP4BETA] global HTTP_*_VARS

From: Date: Sun, 19 Mar 2000 00:18:17 +0000
Subject: Re: [PHP4BETA] global HTTP_*_VARS
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-12387@lists.php.net to get a copy of this message
August Zajonc writes: > I'm using $HTTP_ENV_VARS deep in a couple of includes. Is there anyway to > keep this set of variables in the global scope without having to global them > explicitly. In terms of namespace contention, the HTTP_*_VARS is probably > safe to stick globally, and certainly with an option switch. > > Thanks for any pointers that I may have missed, > > August They should already be in the global scope. All you need to do to use them within any function (even functions in included files or defined within other functions) is to put 'global $HTTP_ENV_VARS;' near the beginning of that function. There is no option in PHP to make global variables accessible inside all functions by default. <?php function foo() { global $HTTP_ENV_VARS; if ( $HTTP_ENV_VARS['somevar'] == 'blarg' ) { . . . } . . . } ?> -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.version4 (#12387) next »