#31045 [Opn->Bgs]: Testing return value of simplexml_load_string
| From: | fmk@php.net | Date: | Thu, 09 Dec 2004 22:53:07 +0000 |
| Subject: | #31045 [Opn->Bgs]: Testing return value of simplexml_load_string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-69994@lists.php.net to get a copy of this message | ||
ID: 31045
Updated by: fmk@php.net
Reported By: rbro at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: SimpleXML related
Operating System: Linux
PHP Version: 5CVS-2004-12-09 (dev)
New Comment:
PHP is loosly typed so comparing an object with a boolean will result
in this behavior.
try comparing with === or check the type of the returned object.
Previous Comments:
------------------------------------------------------------------------
[2004-12-09 23:23:58] rbro at hotmail dot com
Description:
------------
The manual states that simplexml_load_string (and simplexml_load_file)
returns false on any errors. In the following example, I am loading a
valid xml stream, but the simplexml object returned seems to equal
false when it shouldn't.
Reproduce code:
---------------
<?php
$doc = simplexml_load_string('<xml></xml>');
if ($doc == false)
{
echo 'equals false';
}
else
{
echo 'does not equal false';
}
?>
Expected result:
----------------
does not equal false
Actual result:
--------------
equals false
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31045&edit=1