#31045 [WFx]: Testing return value of simplexml_load_string
| From: | rbro at hotmail dot com | Date: | Wed, 15 Dec 2004 13:47:13 +0000 |
| Subject: | #31045 [WFx]: Testing return value of simplexml_load_string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-70274@lists.php.net to get a copy of this message | ||
ID: 31045
User updated by: rbro at hotmail dot com
Reported By: rbro at hotmail dot com
Status: Wont fix
Bug Type: SimpleXML related
Operating System: Linux
PHP Version: 5CVS-2004-12-09 (dev)
New Comment:
Thanks - that makes sense with how simplexml works. So others don't
run into this, would it be possible add to the manual a warning about
this on the simplexml_load_string and simplexml_load_file pages? It's
basically the same idea as the warning currently on
http://www.php.net/strpos. Thanks.
Previous Comments:
------------------------------------------------------------------------
[2004-12-15 13:04:17] chregu@php.net
really not a bug.
simplexml returns an empty string in your case (no text content in
<xml>), which is == false in PHP's loosely typed implementation. Just
use === and it works as expected
------------------------------------------------------------------------
[2004-12-14 09:07:38] derick@php.net
If we have updates, we'll get back to you. No need to keep bugging us.
------------------------------------------------------------------------
[2004-12-13 20:36:28] rbro at hotmail dot com
Just wondering if there is any update on this. I really feel that this
is a bug because there is a difference between the way the mysqli and
simplexml objects work (between the mysqli_connect() and
simplexml_load_string() functions) - since objects should work the same
across the board. Thanks.
------------------------------------------------------------------------
[2004-12-10 00:08:58] rbro at hotmail dot com
Sorry, that code example should have been the following (same result
happens):
<?php
if (($db = mysqli_connect('localhost', 'user', 'password',
'db')) ==
false)
{
echo 'equals false';
}
else
{
echo 'does not equal false';
}
?>
------------------------------------------------------------------------
[2004-12-10 00:07:39] rbro at hotmail dot com
Ok, but then why does this work as expected (when a valid host,
username, password, and db are supplied):
Reproduce code:
---------------
<?php
if (($db = mysqli_connect('localhost', 'user', 'password',
'db')) ===
false)
{
echo 'equals false';
}
else
{
echo 'does not equal false';
}
?>
Expected result:
----------------
does not equal false
Actual result:
--------------
does not equal false
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/31045
--
Edit this bug report at http://bugs.php.net/?id=31045&edit=1