#20064 [NEW]: print_r is still incorrect with referenced objects

From: Date: Thu, 24 Oct 2002 17:21:04 +0000
Subject: #20064 [NEW]: print_r is still incorrect with referenced objects
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-23214@lists.php.net to get a copy of this message
From: laca@webart.hu Operating system: W2K PHP version: 4.2.3 PHP Bug Type: Scripting Engine problem Bug description: print_r is still incorrect with referenced objects Running the code below shows that $cls->tProperty is _NOT_ the same variable as the object itself. However, it should be. It lies that $cls->tProperty is another instance of tClass class. Despite of this, when one changes the name property, it will result in change in both objects, and that's correct. class tClass { var $tProperty; var $name; function tClass() { $this->tProperty =& $this; } }; echo "<pre>"; $cls =& new tClass(); $cls->name = "Sam"; print_r($cls); $cls->name = "George"; print_r($cls); echo "</pre>"; /* ---------------------------- Output: ---------------------------- tclass Object ( [tProperty] => tclass Object ( [tProperty] => *RECURSION* [name] => Sam ) [name] => Sam ) tclass Object ( [tProperty] => tclass Object ( [tProperty] => *RECURSION* [name] => George ) [name] => George ) ---------------------------- Instead of: ---------------------------- tclass Object ( [tProperty] => *RECURSION* [name] => Sam ) tclass Object ( [tProperty] => *RECURSION* [name] => George ) */ -- Edit bug report at http://bugs.php.net/?id=20064&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20064&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20064&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20064&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20064&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20064&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20064&r=support Expected behavior: http://bugs.php.net/fix.php?id=20064&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20064&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20064&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20064&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20064&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20064&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20064&r=isapi

« previous php.bugs (#23214) next »