Re: === on objects fails with recursion! WTH?
| From: | Jochem Maas | Date: | Tue, 01 Nov 2005 15:41:23 +0000 |
| Subject: | Re: === on objects fails with recursion! WTH? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-19886@lists.php.net to get a copy of this message | ||
this is a php4-only problem right?
(or is the little test below insufficient to test the stated problem?)
THIS:
----------------------
php -r '
class A { public $b; function __construct(B $b) { $this->b = $b; $b->setA($this); } }
class B { public $a; function setA(A $a) { $this->a = $a; } }
$y = new B; $x = new A($y);
$z = $x;
$clone = clone $x;
var_dump(($x === $z), ($x === $clone), ($x == $z), ($x == $clone));
'
RETURNS (php5.0.4):
----------------------
bool(true)
bool(false)
bool(true)
bool(true)
Wez Furlong wrote:
I proposed a patch to fix this a while back (at least a year ago). --Wez. On 11/1/05, Amin Azez <azez@ufomechanic.net> wrote:if ($object1===$object2) does a recursive check! "Fatal error: Nesting level too deep - recursive dependency?" Whats going on? I've go lots of object references all highly recursive and I just sometimes need to check if two objects are the same object i.e. they have the same storage address; I don't need to (and can't afford the time) to recursively check every field. Is there a ==== instead that REALLY does what it seems === is trying to fake, presumably to cover up all the object copying that is normally going on but that I've managed to avoid? Sam -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php