ID: 21059 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus -Bug Type: Scripting Engine problem +Bug Type: Class/Object related Operating System: Windows XP, Linux PHP Version: 4.2.3 New Comment:
hello! i found out that THIS IS NOT A BUG. this is how objects work. when using the = operator, the object is copied and the references inside the object still point to the old object. SORRY! Previous Comments: ------------------------------------------------------------------------ [2002-12-17 12:00:07] [EMAIL PROTECTED] here's the output of the script: http://maldini.dyndns.org/~milan/bug.php ------------------------------------------------------------------------ [2002-12-16 20:23:58] [EMAIL PROTECTED] <?PHP class A { var $Text; var $Parent; function A(&$parent, $s) { $this->Text = $s; $this->Parent = &$parent; } } class B { var $Child; function B() { $this->Child =& new A($this, "Hello"); } } class C { var $Child; function C() { $this->Child = new A($this, "Hello"); } } echo "<pre>\n\n"; $b= new B(); $s = serialize($b); echo "$s\n" . strlen($s) . "\n"; $s = serialize(&$b); echo "$s\n" . strlen($s) . "\n"; $b=& new B(); $s = serialize($b); echo "$s\n" . strlen($s) . "\n"; $s = serialize(&$b); echo "$s\n" . strlen($s) . "\n"; $c= new C(); $s = serialize($c); echo "$s\n" . strlen($s) . "\n"; $c=& new C(); $s = serialize(&$c); echo "$s\n" . strlen($s) . "\n"; echo "</pre>"; ?> -------cut----------- hello! i tried this script both on windows and linux with PHP 4.2.3 installed. I saw, that the serialized code could be highly redundant, depending on serializing the object or it's refference. there's also a problem around the new constructor, or i guess, the problem might be at copying objects with the '=' operator... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21059&edit=1