On Apr 16, 2007, at 12:30 PM, Robert Cummings wrote:

[snip]



Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't
generate notices.


Lemme guess... You don't like empty() because it thinks null/0/'' is empty? Or is there some other reason?

Agreed, it can be tricky if you just use it everywhere, but for most things, especially replacing a

if (isset($foo) && $foo != 0/null/''/array()) {}

with

if (!empty($foo))

makes my life a little easier. Especially checking for empty arrays since foreach on an empty array will throw a notice or warning, I forget which atm.

Of course if null/0/'' are considered valid values in your code then you're pretty much stuck with isset() and checking for the value.

And doesn't it also consider 'null' (the string) as empty? Seems like I've read folks complaining that returns from a database that are set to null get missed also... but since I don't have any code that considers null a useful value it's never been a problem for me.

Ed

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to