[php-src] Issue #25336: Empty("0")

From: Date: Mon, 09 Nov 2026 08:09:00 +0000
Subject: [php-src] Issue #25336: Empty("0")
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-254096@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/25336 Author: KarelWintersky ### Description Is it reasonable to hope that the illogical behavior of the empty() will one day be corrected? ``` var_dump(empty(null)); // bool(true) var_dump(empty('')); // bool(true) var_dump(empty('0')); // bool(true) <--- THIS var_dump(empty('0.0')); // bool(false) var_dump(empty(' ')); // bool(false) var_dump(empty('false')); // bool(false) var_dump(empty([])); // bool(true) var_dump(empty(0)); // bool(true) var_dump(empty(0.0)); // bool(true) var_dump(empty(false)); // bool(true) ``` String '0' is not empty really, but the language construct empty considers this to be otherwise. Perhaps one day it will become a function?

« previous php.bugs (#254096) next »