note 120070 deleted from reserved.variables.globals by cmb
| From: | cmb@php.net | Date: | Mon, 07 Nov 2016 15:52:30 +0000 |
| Subject: | note 120070 deleted from reserved.variables.globals by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207043@lists.php.net to get a copy of this message | ||
Note Submitter: vittorio.zamparella at famous googlemail
----
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.