#20064 [Opn->Ver]: print_r is still incorrect with referenced objects
| From: | sniper@php.net | Date: | Sun, 08 Dec 2002 16:54:08 +0000 |
| Subject: | #20064 [Opn->Ver]: print_r is still incorrect with referenced objects | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-27061@lists.php.net to get a copy of this message | ||
ID: 20064
Updated by: sniper@php.net
Reported By: laca@webart.hu
-Status: Open
+Status: Verified
Bug Type: Scripting Engine problem
Operating System: W2K
-PHP Version: 4.2.3
+PHP Version: 4.3.0-dev
Previous Comments:
------------------------------------------------------------------------
[2002-10-24 12:21:04] laca@webart.hu
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 this bug report at http://bugs.php.net/?id=20064&edit=1