php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46122 Simplexmlelement typecasts right to string and int but not to bool
Submitted: 2008-09-19 12:23 UTC Modified: 2008-11-03 01:00 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dirk at heilig-online dot com Assigned:
Status: No Feedback Package: SimpleXML related
PHP Version: 5.2.6 OS: Debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dirk at heilig-online dot com
New email:
PHP Version: OS:

 

 [2008-09-19 12:23 UTC] dirk at heilig-online dot com
Description:
------------
Simplexmlelement->node auto-typecasts right to int or string but a typecast to bool does the same thing as is_set().
to check if a node contains a true or a false value you have to check 
(bool)(string)$simplexmlelement->node.


Reproduce code:
---------------
<?php
$xmlstring="
<xml>
<node>0</node>
</xml>";
$xmlelement=new SimpleXMLElement($xmlstring);
echo "(int)element: ";
var_dump((int)$xmlelement->node);
echo "--\n";
echo "(bool)element: ";
var_dump((bool)$xmlelement->node);
echo "--\n";
echo "(bool)(string)element: ";
var_dump((bool)(string)$xmlelement->node);

Expected result:
----------------
(int)element: int(0)
--
(bool)element: bool(false)
--
(bool)(string)element: bool(false)


Actual result:
--------------
(int)element: int(0)
--
(bool)element: bool(true)
--
(bool)(string)element: bool(false)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-26 11:18 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2008-11-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC