php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31260 Not work constraction of "variable of variable"
Submitted: 2004-12-22 23:34 UTC Modified: 2004-12-23 01:19 UTC
From: sverel at mail dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.8 OS: Windows XP build 2600 (SP2)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sverel at mail dot ru
New email:
PHP Version: OS:

 

 [2004-12-22 23:34 UTC] sverel at mail dot ru
Description:
------------
------

Reproduce code:
---------------
Not working:
<?php
$G= 'GLOBALS';
print "${$G}".'<HR>';
/* printing "Notice: Undefined variable: GLOBALS in C:\http\globals.php on line 22" */
print "${$G}<HR>";
/* printing "Notice: Undefined variable: GLOBALS in C:\http\globals.php on line 23" */

// print $GLOBALS.'<HR>';
?>


Working:
<?php
$G= 'GLOBALS';
print "${$G}".'<HR>'; // printing "Array"
print "${$G}<HR>"; // printing "Array"
print $GLOBALS.'<HR>';
?>

Expected result:
----------------
Notice: Undefined variable: GLOBALS in C:\http\globals.php on line 23

Actual result:
--------------
Array

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-23 01:19 UTC] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

"Variable variables: Superglobals cannot be used as variable variables inside functions or class methods." (c) http://www.php.net/manual/en/language.variables.predefined.php
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Aug 30 04:00:01 2026 UTC