ID:               31045
 User updated by:  rbro at hotmail dot com
 Reported By:      rbro at hotmail dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         SimpleXML related
 Operating System: Linux
 PHP Version:      5CVS-2004-12-09 (dev)
 New Comment:

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.


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

[2004-12-13 20:36:27] 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

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

[2004-12-09 23:53:03] [EMAIL PROTECTED]

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.

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

[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

Reply via email to