#41697 [Opn->Asn]: Impossible to compare simpleXML Objects

From: Date: Mon, 25 Jun 2007 18:43:19 +0000
Subject: #41697 [Opn->Asn]: Impossible to compare simpleXML Objects
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-114198@lists.php.net to get a copy of this message
ID: 41697 Updated by: tony2001@php.net Reported By: judas dot iscariote at gmail dot com -Status: Open +Status: Assigned Bug Type: SimpleXML related Operating System: Irrelevant PHP Version: 5CVS-2007-06-15 (CVS) -Assigned To: +Assigned To: rrichards New Comment: As far as I know, there is no way to compare two different Libxml document pointers, so the result is correct. Rob, please correct me if I'm wrong. Previous Comments: ------------------------------------------------------------------------ [2007-06-15 07:53:29] judas dot iscariote at gmail dot com Description: ------------ You cannot compare simpleXML Objects. Reproduce code: --------------- <?php $xmlstring = '<?xml version="1.0" standalone="yes"?><foo></foo>'; $foo = new SimpleXMLElement($xmlstring); $bar = new SimpleXMLElement($xmlstring); /* "Two object instances are equal if they have the same attributes and values, and are instances of the same class" */ var_dump($foo == $bar); /* object are identical if and only if they refer to the same instance of the same class.*/ var_dump($foo === $bar); ?> Expected result: ---------------- //the are equal bool(true) //but not indentical bool(false) Actual result: -------------- bool(false) bool(false) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41697&edit=1

« previous php.bugs (#114198) next »