|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28237 Can't access built in array whose name is stored in an object attribute
Submitted: 2004-04-30 18:57 UTC Modified: 2004-04-30 19:58 UTC
From: marcel at vernix dot org Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.4 OS: Debian GNU/Linux 2.4.20
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: marcel at vernix dot org
New email:
PHP Version: OS:


 [2004-04-30 18:57 UTC] marcel at vernix dot org
When the name of a built in array is stored inside of an object attribute, its contents can't be access from the 'variable variable' without the use of eval.

So, print_r(${$this->array}) and print_r($$this->array) don't work, but eval("print_r(\${$this->array});") does.

When trying the same thing on a "regular" variable variable, it works as expected.

Reproduce code:
$built_in_array = '_SERVER';

class klass {

    function klass($array = '_SERVER') {
        $this->array = $array;

    function printit() {
        #eval ("print_r(\${$this->array});");


$k = new klass();

Expected result:
    [HZ] => 100
    [TERM] => rxvt
    [SHELL] => /bin/bash
    [WINDOWID] => 31457282

    [HZ] => 100
    [TERM] => rxvt
    [SHELL] => /bin/bash
    [WINDOWID] => 31457282

Actual result:
    [HZ] => 100
    [TERM] => rxvt
    [SHELL] => /bin/bash
    [WINDOWID] => 31457282


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-30 19:58 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 13:01:29 2024 UTC