[php-src] Issue #13242: Undefined variable variable $GLOBALS

From: Date: Wed, 24 Jan 2024 23:28:21 +0000
Subject: [php-src] Issue #13242: Undefined variable variable $GLOBALS
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246336@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13242 Author: jorgsowa ### Description The following code: ```php <?php $variable = 'GLOBALS'; $GLOBALS['GLOBALS'] = 'value'; var_dump($GLOBALS); ``` https://3v4l.org/lpfq6 Resulted in this output: ``` array(8) { ["_GET"]=> array(0) { } ["_POST"]=> ... } ``` But I expected this output instead: ``` string(5) "value" ``` The global variable GLOBALS shouldn't be allowed because it's hidden behind the superglobal. Another problem with this superglobal: Calling $variable = 'GLOBALS';$$variable; outputs Warning: Undefined variable $GLOBALS, but that's not what the user expects, because $GLOBALS is available. I know it's stated in documentation that superglobal array is not allowed, but this error message could be less confusing. https://www.php.net/manual/en/language.variables.variable.php ### PHP Version PHP 8.4 ### Operating System _No response_

« previous php.bugs (#246336) next »