#19056 [Com]: empty() function is completely broken

From: Date: Thu, 22 Aug 2002 20:08:30 +0000
Subject: #19056 [Com]: empty() function is completely broken
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-17589@lists.php.net to get a copy of this message
ID: 19056 Comment by: adets@idsk.com Reported By: adets@idsk.com Status: Bogus Bug Type: Unknown/Other Function Operating System: Linux PHP Version: 4.2.2 New Comment: I don't want to check that is is set (we have isset() fucntion as you noted before), I want to check that it is _not_ empty. If you'll look in the user comments to the empty() function than you'll find that this is a very common problem - usually it has no sence to check that smth. is _not_ zero (because it is more easy to compare it with zero), the task is to check that it is _not_ _empty_, for example, if somebody submits a form it makes a real difference - "" string (_empty_, user passed empty field) and "0" string (that _has_ a value). Now people are using additional checks just because of the fact that empty() function is not working where it should. Previous Comments: ------------------------------------------------------------------------ [2002-08-22 15:52:18] rasmus@php.net The example in the documentation shows clearly that empty() returns true when a var is not set or when it is set to something that evaluates to 0. If you only want to check whether something is set, use the isset() function. ------------------------------------------------------------------------ [2002-08-22 15:47:04] adets@idsk.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? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19056&edit=1

« previous php.bugs (#17589) next »