|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-04-30 19:58 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
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...