|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39251 variable variable class array property is read only
Submitted: 2006-10-25 00:34 UTC Modified: 2006-11-02 01:00 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: taskfreak at gmail dot com Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5.1.6 OS: mac os
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: taskfreak at gmail dot com
New email:
PHP Version: OS:


 [2006-10-25 00:34 UTC] taskfreak at gmail dot com
Acessing class property (which is an array) using a variable makes it read only (can not add a new element)
See code if you don't understand what I mean.
$this->$nameOfArray[$key] = $value;

Using PHP4 style, haven't tried it in PHP5 class coding style. 

I'm under mac os, using php 5.1.6, installed by following this:

Reproduce code:
class test {
  var $arrWhatever;
  function test() {
    $this->arrWhatever = array();
  function set($where,$who, $what) {
     $this->$where[$who] = $what;
  function set2($where,$who,$what) {
     $arrTmp =& $this->$where;
     $arrTmp[$who] = $what;

$obj = new test();



Expected result:
    [key] => value
    [key] => value

Actual result:
    [key] => value


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-25 07:08 UTC]
Please try using this CVS snapshot:
For Windows:
 [2006-11-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 03:02:00 2024 UTC