From:             marcel at vernix dot org
Operating system: Debian GNU/Linux 2.4.20
PHP version:      4.3.4
PHP Bug Type:     Class/Object related
Bug description:  Can't access built in array whose name is stored in an object 
attribute

Description:
------------
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:
---------------
<?php
$built_in_array = '_SERVER';

class klass {

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

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

print_r(${$built_in_array});

$k = new klass();
$k->printit();
?>

Expected result:
----------------
Array
(
    [HZ] => 100
    [TERM] => rxvt
    [SHELL] => /bin/bash
    [WINDOWID] => 31457282
...etc...

Array
(
    [HZ] => 100
    [TERM] => rxvt
    [SHELL] => /bin/bash
    [WINDOWID] => 31457282
...etc...

Actual result:
--------------
Array
(
    [HZ] => 100
    [TERM] => rxvt
    [SHELL] => /bin/bash
    [WINDOWID] => 31457282
...etc...

-- 
Edit bug report at http://bugs.php.net/?id=28237&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28237&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28237&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28237&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28237&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28237&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28237&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28237&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28237&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28237&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28237&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28237&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28237&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28237&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28237&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28237&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28237&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28237&r=float

Reply via email to