php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68540 Documenattion about checking SimpleXML needs clarification
Submitted: 2014-12-03 10:47 UTC Modified: 2017-01-28 12:50 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: seo at gacek dot vot dot pl Assigned:
Status: Verified Package: SimpleXML related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-12-03 10:47 UTC] seo at gacek dot vot dot pl
Description:
------------
---
From manual page: http://www.php.net/language.types.boolean
---

Documentation needs some more information, to clarify when simplexml object is considered true.

More information here: http://stackoverflow.com/a/27157104/1430632


Tried adding it to documentation
  <warning>
   <simpara>
    <literal>SimpleXML</literal> evaluates to &true; only if it has child nodes or properties - only then object is not considered empty.
    To check if <literal>SimpleXML</literal> object has &string; value you have to cast it to &string;
   </simpara>
  </warning>


Patches

Leader (last revision 2017-11-13 05:15 UTC by Terserah26 at gmail dot com)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-27 22:59 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2015-05-27 22:59 UTC] cmb@php.net
I agree that the wording of the documentation is unfortunate:

| SimpleXML objects created from empty tags

An empty tag would most likely be something like <>. Speaking of
empty elements would be better, but would not take into account
that an empty element may have attributes (not properties), and in
this case casting the respective SimpleXML to bool would also
yield true.
 [2017-01-28 12:50 UTC] cmb@php.net
-Package: Documentation problem +Package: SimpleXML related
 [2017-11-13 05:17 UTC] Terserah26 at gmail dot com
Selamat Datang Wahai Pecundang !!!!
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Dec 10 02:01:24 2018 UTC