php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17498 still infinite loop in print_r
Submitted: 2002-05-28 20:35 UTC Modified: 2002-10-19 17:05 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mikx at mikx dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.1 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mikx at mikx dot de
New email:
PHP Version: OS:

 

 [2002-05-28 20:35 UTC] mikx at mikx dot de
There is a note in the documentation that since PHP 4.0.4 infinite loop situations like print_r($GLOBALS) are handled and get stopped. But there are still situations print_r() results in an infinite loop:

foreach($GLOBALS as $i) 
{ 
print_r($GLOBALS); 
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-29 13:07 UTC] yohgaki@php.net
You don't have to report the same bug report.
We know it, it's just nobody care to fix it.


 [2002-10-19 17:05 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2003-03-01 17:49 UTC] qwerty at ut dot ee
in RedHat php-4.2.2 i have noticed thisproblem (is it fixed in some newer version of PHP?):

======PHP CODE STARTS=========
<?php

class test {
        var $nr = 0;
        var $sub1 = null;

        function test() {
                $this->sub1 =& new sub(&$this);
                $this->nr++;
        }
}

class sub {
        var $parent = null;

        function sub($pObj) {
                $this->parent = &$pObj;
        }
}


$mytest =& new test();

print_r($mytest);
?>

======PHP CODE ENDS=========

and outout is following:

test Object
(
    [nr] => 1
    [sub1] => sub Object
        (
            [parent] => test Object
                (
                    [nr] => 1
                    [sub1] =>  *RECURSION*
                )

        )

)

but the problem is: the *RECURSION* must allready be in [parent] because the [parent] is a pointer/reference to parent object...

am i right or wrong ?

in more complicated solutions where are more objects that use  references to their parents, print_r()  can not handle the recursion well and results in an infinite loop...
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Mar 27 02:00:01 2026 UTC