|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
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-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 04 03:01:27 2023 UTC