|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-01-20 20:15 UTC] seanr at webolutionary dot com
Description: ------------ If the value is a string of "0", than it's not a true zero right? The behavior of empty() in this case is utterly absurd. If you can't fix empty, there needs to be a new function to provide a better way to test on this than writing our own special functions to work around a PHP bug. $a = 0; $b = ''; $b = '0' empty($a) returns true (correctly, but not helpfully) empty($b) returns true (correctly) empty($a) returns true (incorrectly, since it actually does have a value) Of course, isset() returns true for all three (correctly, but not helpfully). This means there's no way to find out that $a and $c have values I can use and $b doesn't without writing my own special function or if statement. EXTREMELY frustrating. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 07:00:01 2025 UTC |
equivalence is not transitive: var_dump("a" == 0, 0 == "b", "a" == "b"). empty is simply awkwardly named. empty($v) is simply equivalent to !isset($v) || !$v.