Re: Recursive classes ... possible bug?

From: Date: Wed, 06 Jun 2007 00:30:23 +0000
Subject: Re: Recursive classes ... possible bug?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-30101@lists.php.net to get a copy of this message
On 6/5/07, mark@cyanox.nl <mark@cyanox.nl> wrote:
Paweł Stradomski wrote: mark@cyanox.nl wrote:
Dear internals, I stumbled upon the following odd error message from PHP which I was not expecting. function test(){
    echo $this == $this->c1->c2?'equals':'not equals'; // Somehow this
Use === (shallow test - returns true iff the variables refer to the same instance) instead of == (deep comparision - member-by-member). Still in theory it should not produce an error.
Yes, it should. == is going to test all the properties of the object against each other. So to compare. $this == $this->c1->c2, it will compare $this->c1 == $this->c1->c2->c1, which will in turn compare $this->c1->c2 == $this->c1->c2->c1->c2, which in turn compares $this->c1->c2->c1 == $this->c1->c2->c1->c2->c1 And so on. -- --Robert Deaton

« previous php.internals (#30101) next »