Bug #75743 [Opn]: ${$<superglobal variable>} inside function does not work
| From: | danack@php.net | Date: | Thu, 28 Dec 2017 13:47:51 +0000 |
| Subject: | Bug #75743 [Opn]: ${$<superglobal variable>} inside function does not work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213308@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75743&edit=1
ID: 75743
Updated by: danack@php.net
Reported by: works dot devel at gmail dot com
Summary: ${$<superglobal variable>} inside function does not
work
Status: Open
Type: Bug
Package: Arrays related
Operating System: Ubuntu
PHP Version: 7.1.12
Block user comment: N
Private report: N
New Comment:
I'm not sure the reason, but this is defined behaviour http://php.net/manual/en/language.variables.superglobals.php:
Note: Variable variables
Superglobals cannot be used as variable variables inside functions or class methods.
Previous Comments:
------------------------------------------------------------------------
[2017-12-28 13:31:59] works dot devel at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/reserved.variables.get
---
function f() {
$var = '_GET';
print_r(${$var});
}
f();
Test script:
---------------
http://localhost/my-script.php?foo=bar
Expected result:
----------------
Array ( foo => bar )
Actual result:
--------------
Notice: Undefined variable: _GET in ...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75743&edit=1