Edit report at https://bugs.php.net/bug.php?id=65223&edit=1
ID: 65223
User updated by: truenrush at gmail dot com
Reported by: truenrush at gmail dot com
Summary: $_SERVER, $_ENV, $_REQUEST variables missing in
$GLOBALS
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Debian
PHP Version: 5.4.17
Block user comment: N
Private report: N
New Comment:
Thanks for so fast response. I was near to blow my brain up.
Now i understand how it really works inside. Cool feature! :)
Previous Comments:
------------------------------------------------------------------------
[2013-07-09 12:00:54] [email protected]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
super-globals (aka. auto globals) are not added to symbol tables by defaultfor
performance reasons unless the parser sees need. i.e.
<?php
$_SERVER;
print_r($GLOBALS);
?>
will list it. You can also control this using auto_gloals_jit in php.ini:
http://www.php.net/manual/en/ini.core.php#ini.auto-globals-jit
------------------------------------------------------------------------
[2013-07-09 11:20:19] truenrush at gmail dot com
I also found that $_ENV and $_REQUEST vars are also missing in $GLOBALS.
_SERVER variable appears in $GLOBALS when using php in cli mode, but with web
server i can not find it in the $GLOBALS variable
------------------------------------------------------------------------
[2013-07-09 10:40:30] truenrush at gmail dot com
Description:
------------
When i did a var_dump($GLOBALS) i was surprized, because _SERVER variable was
missing here, but standalone _SERVER var was working fine.
According to http://www.php.net/manual/en/reserved.variables.globals.php,
"$GLOBALS is an associative array containing references to all variables which
are
currently defined in the global scope of the script".
_SERVER is defined in global space. But it does not appear in the $GLOBALS.
I found nothing on php.net about such behaviour.
Test script:
---------------
var_dump($GLOBALS);
Expected result:
----------------
_SERVER key exists in $GLOBALS array.
Actual result:
--------------
_SERVER key does not exist in $GLOBALS array.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65223&edit=1