For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > June 2007 > #41697 [Bgs->Opn]: Impossible to compare simpleXML Objects









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #41697 [Bgs->Opn]: Impossible to compare simpleXML Objects
judas dot iscariote at gmail dot com

2007-06-27, 8:00 am

ID: 41697
User updated by: judas dot iscariote at gmail dot com
Reported By: judas dot iscariote at gmail dot com
-Status: Bogus
+Status: Open
-Bug Type: SimpleXML related
+Bug Type: Documentation problem
Operating System: Irrelevant
PHP Version: 5CVS-2007-06-15 (CVS)
Assigned To: rrichards
New Comment:

This gotcha should be mentioned in the documentation then .


Previous Comments:
------------------------------------------------------------------------

[2007-06-26 12:32:46] rrichards@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Tony's assessment is correct

------------------------------------------------------------------------

[2007-06-25 18:43:19] tony2001@php.net

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.

------------------------------------------------------------------------

[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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com