|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-08-22 15:47 UTC] adets at idsk dot com
empty() function is not working correctly.
It returns true if variable has a value of: 0 & 0.0
(integer, float), false (boolean) or "0" (string).
This makes this function COMPLETELY USELESS.
Is it possible to implement this function correctly (it
will be great!!!), remove it at
all (because it is useless now) or at least correct
documentation?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 04:00:02 2025 UTC |
Well, it has always been documented to work like this and it isn't going to change as it would break countless applications. And it is only "useless" for fields where "0" is valid input. For those use isset()&&strlen(). Basically empty() works the same as just doing if($var) and if("0") is still false, so any other behaviour would be inconsistent.