php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79126 empty() documentation does not mention SimpleXML objects from empty tags
Submitted: 2020-01-15 19:28 UTC Modified: 2020-12-07 14:40 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: dse at webonastick dot com Assigned: cmb (profile)
Status: Closed Package: SimpleXML related
PHP Version: 7.4.1 OS: macOS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dse at webonastick dot com
New email:
PHP Version: OS:

 

 [2020-01-15 19:28 UTC] dse at webonastick dot com
Description:
------------
---
From manual page: https://php.net/function.empty
---

<https://php.net/function.empty> mentions that for the following values, empty() will return TRUE:

- an unset variable
- ""
- 0
- 0.0
- "0"
- NULL
- FALSE
- array()

The documentation does not mention that a SimpleXML object from an empty tag is also considered empty, thus empty() also returns TRUE for one.

I figured this out after checking <https://www.php.net/manual/en/language.types.boolean.php> while writing something for a PHP cheatsheet.

Test script:
---------------
$ php -r '$foo = new SimpleXMLElement("<html>5</html>"); print $foo ? "truthy\n" : "falsy\n";'
truthy

$ php -r '$foo = new SimpleXMLElement("<html></html>"); print $foo ? "truthy\n" : "falsy\n";'
falsy



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-07 14:40 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=351947
Log: Fix #79126: empty() documentation does not mention SimpleXML objects from empty tags

To avoid duplication, we refer to falsey values instead.
 [2020-12-07 14:40 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2020-12-07 14:42 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=3ae0b14dd06ea9d47728f366dfe2c29476a2468e
Log: Fix #79126: empty() documentation does not mention SimpleXML objects from empty tags
 [2020-12-07 14:42 UTC] phpdocbot@php.net
-Status: Verified +Status: Closed
 [2020-12-07 19:58 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=351948
Log: Fix #79126: empty() documentation does not mention SimpleXML objects from empty tags

To avoid duplication, we refer to falsey values instead.
 [2020-12-07 20:00 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=5b32b887688d95783e1a572ad2bebd2d508f8061
Log: Fix #79126: empty() documentation does not mention SimpleXML objects from empty tags
 [2020-12-30 11:58 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=d1e92a89616aaafe89ebea3686178b3f57142a5b
Log: Fix #79126: empty() documentation does not mention SimpleXML objects from empty tags
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC