Re: questions about $_SERVER

From: Date: Mon, 12 Mar 2012 21:17:52 +0000
Subject: Re: questions about $_SERVER
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-316998@lists.php.net to get a copy of this message
The purpose of the "global" statement within a function is to let PHP know that the usage of a var name INSIDE that function is not meant to create a NEW variable, but instead, to reference the other (global) variable being used (and perhaps already defined) in your main script. Basically it works like this: You can: - create vars in the main script usable in that script's main body outside of any functions - create vars to be used entirely and only within any functions in your script; -reference vars from the main script within a specific function by referencing them with a "global $xxx,$yyy,$zzz" statement at the top of your function; And Finally You Can: - create $_SESSION['xxx'] var that can be seen anywhere in your application(s) during the life of the current session. Close the browser or fail to do a "session_start()" in a script and you can't see them, but who would do that? I'm sure someone will have something else to add, but I think this is all the knowledge one needs to accomplish most php programming.

« previous php.general (#316998) next »