php-general Digest 10 Mar 2012 15:38:02 -0000 Issue 7721
Topics (messages 316962 through 316962):
Re: questions about $_SERVER
316962 by: Tedd Sperling
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Mar 9, 2012, at 10:20 PM, Jim Giner wrote:
> "tamouse mailing lists" <tamouse.li...@gmail.com> wrote in message
> news:CAHUC_t8g43GE3xqvSU5SwFePGS1XG=tk1mhrbem9gjaarve...@mail.gmail.com...
>> On Mon, Feb 13, 2012 at 2:39 PM, Tedd Sperling <tedd.sperl...@gmail.com>
>> wrote:
>>> On Feb 13, 2012, at 4:10 AM, Stuart Dallas wrote:
>>>> On 13 Feb 2012, at 06:28, Rui Hu wrote:
>>>>> How PHP sets variables in $_SERVER, say, $DOCUMENT_ROOT? What should I
>>>>> know
>>>>> if I want to modify $_SERVER myself?
>>>>
>>>> Once your script starts the superglobals are no different to any other
>>>> variables, except that they're in scope at all times.
>>>
>>> That's probably the reason why they are named "SuperGlobals". :-)
>>>
>>> But to be more descriptive, these are simply globals that are predefined
>>> by php -- see:
>>>
>>> http://php.net/manual/en/language.variables.superglobals.php
>>>
>>> I believe, (please show me otherwise) there are no "globals" in PHP other
>>> than SuperGlobals.
>>
>> Assuming you mean pre-defined ones, there shouldn't be, since no other
>> ones are documented. If there are, then either they should be
>> documented, or they should be ignored as it can be dangerous to use
>> undocumented features. :)
>
> Just to be clear - you asked if it were true that "there are no "globals" in
> PHP other than SuperGlobals: Don't forget that anything that you declare as
> global in a script is a global for that instance of that script (and
> whatever includes, etc. that it calls during its run)
That's correct, but to access those variables outside of their scope (such as a
function) you do via a SuperGlobal, namely $GLOBAL['whatever'].
As such, there are no "globals" in PHP other than SuperGlobals. As I said, if
I'm wrong, please show me otherwise.
Cheers,
tedd
_____________________
tedd.sperl...@gmail.com
http://sperling.com
--- End Message ---