| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2004-07-15 04:27 UTC] webmaster at ragnarokonline dot de
 Description: ------------ $_GLOBALS somehow doesn't contain the arrays $_REQUEST, $_ENV and $_SERVER. This worked fine in PHP4. Reproduce code: --------------- <?php var_dump($GLOBALS['_SERVER']); var_dump($GLOBALS['_ENV']); var_dump($GLOBALS['_REQUEST']); ?> Expected result: ---------------- The contents of the arrays $_SERVER, $_ENV and $_REQUEST are being printed. Actual result: -------------- NULL NULL NULL is being printed. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 09:00:01 2025 UTC | 
mmh ... or even $GLOBALS in general, so var_dump($GLOBALS) would include $_SERVER, $_ENV and $_REQUEST and scripts, like <?php var_dump(in_array('_SERVER', array_keys($GLOBALS))); ?> work as expected, which means the above script would return bool(true) for example?An alternative to the workaround of putting "register_long_arrays = On", in php.ini is to include a reference to $_SERVER (etc) *anywhere* in your PHP script. This seems to trigger the population of $GLOBALS with the correct data. The following example demonstrates this. Un-comment the lines at the bottom to implement and demonstrate the work-around. echo "_SERVER array is {$GLOBALS['_SERVER']} <BR>"; echo "_GET array is {$GLOBALS['_GET']} <BR>"; echo "_POST array is {$GLOBALS['_POST']} <BR>"; echo "_FILES array is {$GLOBALS['_FILES']} <BR>"; echo "_COOKIE array is {$GLOBALS['_COOKIE']} <BR>"; echo "_REQUEST array is {$GLOBALS['_REQUEST']} <BR>"; echo "_ENV array is {$GLOBALS['_ENV']} <BR><BR>"; //echo "\$_SERVER is $_SERVER<BR>"; //echo "\$_REQUEST is $_REQUEST<BR>"; //echo "\$_ENV is $_ENV<BR>";