2 ms·
http://www.zachstronaut.com/posts/2009/02/09/careful-with-php-empty.html http://www.zachstronaut.com/posts/2009/02/09/careful-with-ph... http://stackoverflow.c
by debacle 14y ago
http://www.zachstronaut.com/posts/2009/02/09/careful-with-php-empty.html http://www.zachstronaut.com/posts/2009/02/09/careful-with-ph...
http://stackoverflow.com/questions/410002/fixing-the-php-empty-function http://stackoverflow.com/questions/410002/fixing-the-php-emp...
The behavior of empty is unreliable. isset is not ambiguous.
- wvenable 14y agoEmpty is identical to the not operator (!) except it also works on undefined variables, properties, and keys.
- ChiperSoft 14y agoI could see it being depreciated for use on non-arrays, but at the moment the only other method of detecting an empty array is `!count($arr)`, which is significantly slower if the array isn't empty. Ultimately this isn't a language issue, it's a training issue. If you're using empty in place of isset, you're doing it wrong, the both serve completely different purposes.
- smsm42 14y agoWhat you mean "unreliable"? It is completely reliable and described in the documentation. It doesn't fit some use cases, in these cases you could use other facilities provided by the language, PHP can not have separate language construct for every use case.