note 124286 added to function.debug-backtrace

From: Date: Fri, 11 Oct 2019 06:50:13 +0000
Subject: note 124286 added to function.debug-backtrace
Groups: php.notes 
Request: Send a blank email to php-notes+get-212574@lists.php.net to get a copy of this message
I want to point out that debug_backtrace() in new versions of php can detect recursion // circular references .. avoiding memory consumption. Example: <?php class ParentClass { public function __construct() { $this->_child = new ChildClass($this); var_dump(debug_backtrace()); } } class ChildClass { public function __construct(ParentClass $p) { $this->_parent = $p; } } $test = new ParentClass(); ?> Output: array(1) { [0]=> array(7) { ["file"]=> string(23) "/home/jcm/testdebug.php" ["line"]=> int(18) ["function"]=> string(11) "__construct" ["class"]=> string(11) "ParentClass" ["object"]=> object(ParentClass)#1 (1) { ["_child"]=> object(ChildClass)#2 (1) { ["_parent"]=> *RECURSION* } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Attention in the *RECURSION* hint provided ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.168 (proxied: 87.191.35.218) ---- Manual Page -- http://php.net/manual/en/function.debug-backtrace.php Edit -- https://master.php.net/note/edit/124286 Del: integrated -- https://master.php.net/note/delete/124286/integrated Del: useless -- https://master.php.net/note/delete/124286/useless Del: bad code -- https://master.php.net/note/delete/124286/bad+code Del: spam -- https://master.php.net/note/delete/124286/spam Del: non-english -- https://master.php.net/note/delete/124286/non-english Del: in docs -- https://master.php.net/note/delete/124286/in+docs Del: other reasons-- https://master.php.net/note/delete/124286 Reject -- https://master.php.net/note/reject/124286 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#212574) next »