Bug #17239 Updated: Objects copying

From: Date: Sat, 01 Jun 2002 13:39:23 +0000
Subject: Bug #17239 Updated: Objects copying
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-9060@lists.php.net to get a copy of this message
ID: 17239 Updated by: mfischer@php.net Reported By: vbv@arte.ru -Status: Open +Status: Closed Bug Type: Class/Object related Operating System: Linux PHP Version: 4.2.1 New Comment: This is no longer an issue with ZE2 in which case every echo returns '17' which is the expected behaviour. Previous Comments: ------------------------------------------------------------------------ [2002-05-15 05:48:47] vbv@arte.ru There is a bug with getting copy of object where 1th object has another 2th object and 2th object has another 3th object. When i copy 2th object to any variable i must have 2th object in 1th and 2th object in variable. It must be equals but not 2 links to one object. Look at this code and make changes as recommends in conmment. <? class a { var $i; function a () { $this->i = 1; } function set_i ($p) { $this->i = $p; } function get_i () { return $this->i; } } class b { function b () { $this->a = new a (); } function set_id ($p) { $this->a->set_i ($p); } function get () { return $this->a->get_i (); } } class c { function c () { $this->item = new b (); } } $cat= new c(); $z1 = $cat->item; // Comment this line $cat->item->set_id (12); $z = $cat->item->a; //$z1 = $cat->item; // Decomment this line $cat->item->set_id (17); echo "<br>C: i: ".$cat->item->get(); echo "<br>Z: i: ".$z->get_i (); echo "<br>Z: i: ".$z1->get (); if ($cat->item->get() == $z1->get ()) echo " - <font color=red>Getting BUG here. There must be '1' value!</font>"; ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17239&edit=1

« previous php.bugs (#9060) next »