|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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);
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Mar 27 04:00:02 2026 UTC |
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...