Doc #68540 [Opn->Ver]: Documenattion about checking SimpleXML needs clarification
| From: | cmb@php.net | Date: | Wed, 27 May 2015 22:59:13 +0000 |
| Subject: | Doc #68540 [Opn->Ver]: Documenattion about checking SimpleXML needs clarification | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12374@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68540&edit=1
ID: 68540
Updated by: cmb@php.net
Reported by: seo at gacek dot vot dot pl
Summary: Documenattion about checking SimpleXML needs
clarification
-Status: Open
+Status: Verified
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2014-12-03 10:47:56] 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>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68540&edit=1