ID:               39866
 Updated by:       [EMAIL PROTECTED]
 Reported By:      liatb at marvell dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         SimpleXML related
 Operating System: windows
 PHP Version:      5.2.0
 New Comment:

That's right. Object are equal only if they point to the same libxml2
data. 
You must cast the objects to strings first if you want to compare them
as strings.
See "Example 5" at http://php.net/simplexml.


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

[2006-12-18 13:22:03] liatb at marvell dot com

Description:
------------
I  upgraded my PHP version from 5.1.* to 5.2.0
XML string loaded into two different simpleXML objects.
The result of comparing xml node attributes (without any specific cast)
in version 5.2.0 is different then used to be in 5.0.3 and 5.1.5.
I also checked the last snapshot for windows marked as "PHP Version
5.2.1RC2-dev" and got the same output as 5.2.0

Reproduce code:
---------------
<?php


$xmlStr = "<test id=\"5\"><name>hello</name></test>";

$xml_1 = simplexml_load_string($xmlStr);

$xml_2 = simplexml_load_string($xmlStr);

var_dump($xml_1);
var_dump($xml_2);

print("<br/>");

if($xml_1['id'] == $xml_2['id']) {
    print("equal ids");
}
else
{
    print("not equal ids");
}

print("<br/>");
if($xml_1->name == $xml_2->name)
{
    print("equal names");
}
else
{
    print("not equal names");
}

?>


Expected result:
----------------
equal ids
equal names

Actual result:
--------------
not equal ids
not equal names


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


-- 
Edit this bug report at http://bugs.php.net/?id=39866&edit=1

Reply via email to