note 120070 added to reserved.variables.globals
| From: | vittorio.zamparellaatfamousgooglemail | Date: | Thu, 20 Oct 2016 23:02:39 +0000 |
| Subject: | note 120070 added to reserved.variables.globals | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206933@lists.php.net to get a copy of this message | ||
Maybe it's old news, but not all superglobals are accessibles via $GLOBALS:
<?php
foreach ( array('GLOBALS', '_SERVER', '_GET', '_POST',
'_FILES', '_COOKIE', '_SESSION', '_REQUEST',
'_ENV') as $varName) {
echo 'isset($GLOBALS[$'.$varName.']) : ';
var_dump(isset($GLOBALS[$varName]));
}
?>
yelds:
Output for 5.4.0 - 5.6.27, 7.0.0 - 7.1.0RC4
isset($GLOBALS[$GLOBALS]) : bool(true)
isset($GLOBALS[$_SERVER]) : bool(true)
isset($GLOBALS[$_GET]) : bool(true)
isset($GLOBALS[$_POST]) : bool(true)
isset($GLOBALS[$_FILES]) : bool(true)
isset($GLOBALS[$_COOKIE]) : bool(true)
isset($GLOBALS[$_SESSION]) : bool(false)
isset($GLOBALS[$_REQUEST]) : bool(false)
isset($GLOBALS[$_ENV]) : bool(false)
Output for hhvm-3.10.0 - 3.14.4
isset($GLOBALS[$GLOBALS]) : bool(true)
isset($GLOBALS[$_SERVER]) : bool(true)
isset($GLOBALS[$_GET]) : bool(true)
isset($GLOBALS[$_POST]) : bool(true)
isset($GLOBALS[$_FILES]) : bool(true)
isset($GLOBALS[$_COOKIE]) : bool(true)
isset($GLOBALS[$_SESSION]) : bool(true)
isset($GLOBALS[$_REQUEST]) : bool(true)
isset($GLOBALS[$_ENV]) : bool(true)
Output for 4.3.0 - 5.3.29
isset($GLOBALS[$GLOBALS]) : bool(true)
isset($GLOBALS[$_SERVER]) : bool(true)
isset($GLOBALS[$_GET]) : bool(true)
isset($GLOBALS[$_POST]) : bool(true)
isset($GLOBALS[$_FILES]) : bool(true)
isset($GLOBALS[$_COOKIE]) : bool(true)
isset($GLOBALS[$_SESSION]) : bool(false)
isset($GLOBALS[$_REQUEST]) : bool(true)
isset($GLOBALS[$_ENV]) : bool(true)
I don't think it's a bug but I'll file a bug report to inquiry among people who know.
I'm not trying to circumvent the "no bug reports" sign, I just think it should be
noted because the documentation doesn't mention it.
----
Server IP: 72.52.91.14
Probable Submitter: 2.37.110.33
----
Manual Page -- http://php.net/manual/en/reserved.variables.globals.php
Edit -- https://master.php.net/note/edit/120070
Del: integrated -- https://master.php.net/note/delete/120070/integrated
Del: useless -- https://master.php.net/note/delete/120070/useless
Del: bad code -- https://master.php.net/note/delete/120070/bad+code
Del: spam -- https://master.php.net/note/delete/120070/spam
Del: non-english -- https://master.php.net/note/delete/120070/non-english
Del: in docs -- https://master.php.net/note/delete/120070/in+docs
Del: other reasons-- https://master.php.net/note/delete/120070
Reject -- https://master.php.net/note/reject/120070
Search -- https://master.php.net/manage/user-notes.php