php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20064 print_r is still incorrect with referenced objects
Submitted: 2002-10-24 12:21 UTC Modified: 2003-02-10 11:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: laca at webart dot hu Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.0-dev OS: W2K
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: laca at webart dot hu
New email:
PHP Version: OS:

 

 [2002-10-24 12:21 UTC] laca at webart dot 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
)


*/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-10 11:00 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The 1st instance of recursion is always shown. Consider print_r($GLOBALS);
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 20 23:00:02 2025 UTC