Bug #75743 [Opn->Nab]: ${$<superglobal variable>} inside function does not work

From: Date: Tue, 02 Jan 2018 13:10:38 +0000
Subject: Bug #75743 [Opn->Nab]: ${$<superglobal variable>} inside function does not work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213353@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: cmb@php.net Reported by: works dot devel at gmail dot com Summary: ${$<superglobal variable>} inside function does not work -Status: Open +Status: Not a bug Type: Bug -Package: Arrays related +Package: Scripting Engine problem Operating System: Ubuntu PHP Version: 7.1.12 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Since the behavior is documented as such, this is not a bug. Changing the current behavior would require an RFC. Feel free to start the process[1]. :) [1] <https://wiki.php.net/rfc/howto> Previous Comments: ------------------------------------------------------------------------ [2017-12-28 13:47:50] danack@php.net 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#213353) next »