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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 + 7 = ?
Subscribe to this entry?

 
 [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 22:01:27 2024 UTC