Re: questions about $_SERVER

From: Date: Sun, 11 Mar 2012 19:04:00 +0000
Subject: Re: questions about $_SERVER
Groups: php.general 
Request: Send a blank email to php-general+get-316986@lists.php.net to get a copy of this message
On 11 Mar 2012 at 18:16, Tedd Sperling <tedd.sperling@gmail.com> wrote: > On Mar 11, 2012, at 10:25 AM, Daniel Brown wrote: > >> On Sat, Mar 10, 2012 at 10:37, Tedd Sperling <tedd.sperling@gmail.com> wrote: >>> As such, there are no "globals" in PHP other than SuperGlobals. As I said, >>> if I'm wrong, please show me otherwise. >> >> A superglobal is predefined at run-time by the parser, >> environment, SAPI, etc. (_SERVER, _POST, _GET, _REQUEST, _ENV, >> _SESSION, _COOKIE), whereas a global can be defined at any time, and >> is available to the current instance. All superglobals are globals, >> but not all globals are superglobals. > Now I'm confused. > > My understanding is that all variables defined within the main script are > accessible within the main script because they are all within scope by > definition. > > Additionally, main script variables are not accessible out of scope (such as > in a function) unless one uses $GLOBALS to retrieve those values. 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

« previous php.general (#316986) next »