php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39426 problem wih __get ant multidimensional arrays
Submitted: 2006-11-08 08:57 UTC Modified: 2006-11-08 13:25 UTC
From: wmalota at php-art dot pl Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.0 OS: Linux/Debian
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wmalota at php-art dot pl
New email:
PHP Version: OS:

 

 [2006-11-08 08:57 UTC] wmalota at php-art dot pl
Description:
------------
Copying an array returned by __get to other array returned by __get from other object gives wrong effect.

Reproduce code:
---------------
class test {
  private $variables = array();

  public function & __get($name) {
    return $this->variables[$name];
  }
  public function __set($name, $value) {
    $this->variables[$name] = $value;
  }
}

$test1 = new test;
$test1->data['sth1'] = 'sth1';
$test1->data['sth2'] = 'sth2';

$test2 = new test;
$test2->data['rewritten'] = $test1->data;

echo($test2->data['rewritten']['sth1']);

Expected result:
----------------
I expected that on the screen I see this text:

sth1

On PHP 5.1.x it works properly.

Actual result:
--------------
On the screen I see text:

Array

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-08 13:25 UTC] tony2001@php.net
Turn on error reporting and you'll see:

Notice: Indirect modification of overloaded property test::$data has no effect in /tmp/2.php on line 15

Notice: Indirect modification of overloaded property test::$data has no effect in /tmp/2.php on line 16

Notice: Indirect modification of overloaded property test::$data has no effect in /tmp/2.php on line 19
NULL

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC