Doc #79126 [Opn->Ver]: empty() documentation does not mention SimpleXML objects from empty tags

From: Date: Mon, 07 Dec 2020 14:40:41 +0000
Subject: Doc #79126 [Opn->Ver]: empty() documentation does not mention SimpleXML objects from empty tags
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18209@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79126&edit=1 ID: 79126 Updated by: cmb@php.net Reported by: dse at webonastick dot com Summary: empty() documentation does not mention SimpleXML objects from empty tags -Status: Open +Status: Verified Type: Documentation Problem Package: SimpleXML related Operating System: macOS PHP Version: 7.4.1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2020-12-07 14:40:22] 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-01-15 19:28:11] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79126&edit=1

« previous php.doc.bugs (#18209) next »