Re: Object Equality
| From: | Robert Cummings | Date: | Thu, 09 Oct 2003 03:13:49 +0000 |
| Subject: | Re: Object Equality | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4767@lists.php.net to get a copy of this message | ||
On Wed, 2003-10-08 at 10:21, LingWitt@insightbb.com wrote:
> (Note: this email seems to relate to this list in my opinion, but I
> have been chewed out before when posting such emails)
>
> I am using PHP 4.3.2, and it seems that testing objects for equality
> (with == or ===) causes an internal bug when the objects have recursive
> instance variables. That is, if the objects being tested have a
> variable that is a reference to an object that has a variable that is a
> reference to the first object, then the PHP processor dies. What can be
> done about this? If this needs to be sent to another mailing list,
> please let me know.
Dirty hack -- create a unique ID instance variable for objects via their
constructor. Implement equality check with:
if( $obj1->uid == $obj2->uid )
{
// Same object, yaaaaaaaaaaay!
}
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'