php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #41697 Impossible to compare simpleXML Objects
Submitted: 2007-06-15 07:53 UTC Modified: 2007-08-17 02:14 UTC
From: judas dot iscariote at gmail dot com Assigned: rrichards (profile)
Status: Closed Package: Documentation problem
PHP Version: 5CVS-2007-06-15 (CVS) OS: Irrelevant
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: judas dot iscariote at gmail dot com
New email:
PHP Version: OS:

 

 [2007-06-15 07:53 UTC] 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)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-25 18:43 UTC] 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-26 12:32 UTC] 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-27 08:46 UTC] judas dot iscariote at gmail dot com
This gotcha should be mentioned in the documentation then .
 [2007-08-17 02:14 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Extensions can define own rules for their objects comparison."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 21 01:00:03 2025 UTC