|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-25 19:39 UTC] jesse at mactechs dot com
[2004-03-28 20:22 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 17:00:01 2025 UTC |
Description: ------------ Recursive object reference comparisons fail in PHP4.x. Alternative to my "exptected result" below, I would settle for one of a couple of things. One would be a boolean comparison function that returns true if two references point to the same data, or another could be simply a boolean function that returns true if two objects are the same (with recursing to all the values). I'm aware the Zend Engine 2/PHP5 identity operator works in the fashion I'd like now, but I'd still consider this a bug for Zend Engine/PHP4. Reproduce code: --------------- // key failing element here is B::is_ref class A { var $a_ref; function set_ref (&$obj) { $this->a_ref =& $obj; } } class B { var $b_ref; function set_ref (&$obj) { $this->b_ref =& $obj; } function is_ref (&$obj) { if ($obj === $this->b_ref) return true; } } $a = new A; $b = new B; $a->set_ref ($b); $b->set_ref ($a); var_dump ($b->is_ref ($a)); Expected result: ---------------- I would expect that "if ($obj === $this->b_ref)" would return true if they (the two object references being compared) referenced the same object, and false if they didnt. Please see my description, as well. Actual result: -------------- " Fatal error: Nesting level too deep - recursive dependency? in /path-to/test.php on line 12 "