From: james at processit dot biz Operating system: Windows Server 2003 PHP version: 5.0.0 PHP Bug Type: *General Issues Bug description: $array[xyz] = xyz; doesn't work inside a class
Description: ------------ In a function inside a class, I can only set array elements through the $xyz = array("key"=>"val") syntax. If I attempt to set with $xyz['key'] = 'val', the whole array is replaced with 'val' and it just becomes a normal variable, not an array. Reproduce code: --------------- <?php class Test { public $array; function arraytester() { $this->$array = array("key1"=>"val1", "key2"=>"val2"); print_r($this->$array); $this->$array['key1'] = 'val3'; print_r($this->$array); } } $class = new Test; $class->arraytester(); ?> Expected result: ---------------- Array ( [key1] => val1 [key2] => val2 ) Array ( [key1] => val3 [key2] => val2 ) Actual result: -------------- Array ( [key1] => val1 [key2] => val2 ) val3 -- Edit bug report at http://bugs.php.net/?id=30202&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30202&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30202&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30202&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30202&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30202&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30202&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30202&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30202&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30202&r=support Expected behavior: http://bugs.php.net/fix.php?id=30202&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30202&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30202&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30202&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30202&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30202&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30202&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30202&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30202&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30202&r=mysqlcfg