|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2004-12-09 23:23 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 06:00:01 2025 UTC | 
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 falseSorry, 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'; } ?>