Re: isset
| From: | Edward Vermillion | Date: | Mon, 16 Apr 2007 18:16:35 +0000 |
| Subject: | Re: isset | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253044@lists.php.net to get a copy of this message | ||
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