Bug #63583 [Nab]: Comparing objects is wrong
Edit report at https://bugs.php.net/bug.php?id=63583&edit=1
ID: 63583
User updated by: vadimx at gmail dot com
Reported by: vadimx at gmail dot com
Summary: Comparing objects is wrong
Status: Not a bug
Type: Bug
Package: SimpleXML related
Operating System: *
PHP Version: 5.3.18
Block user comment: N
Private report: N
New Comment:
So, for compare 2 SimpleXMLElement objects, i have one, not good way
var_dump($o1->asXML() == $o2->asXML()), but it's wrong if one space (or \n \t)
before tag name are different?
Or exists another method, for check if 2 SimpleXMLElement objects are same?
Previous Comments:
------------------------------------------------------------------------
[2012-11-23 01:52:35] aharvey@php.net
SimpleXML does implement object comparison, but it compares both the underlying document and node
â if they aren't the same (and they aren't, in this case, since both new
SimpleXMLElement() calls create new documents and nodes), then the objects aren't the same.
------------------------------------------------------------------------
[2012-11-22 16:40:48] vadimx at gmail dot com
Description:
------------
Comparing objects always returns false. How can i compare objects?
Test script:
---------------
$xml = '<a><b/></a>';
$a = new SimpleXMLElement($xml);
$b = new SimpleXMLElement($xml);
var_dump($a == $b);
Expected result:
----------------
bool(true)
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63583&edit=1
Thread (3 messages)