Re: Type of form element
| From: | Ben Ramsey | Date: | Wed, 09 Nov 2005 04:52:28 +0000 |
| Subject: | Re: Type of form element | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-225402@lists.php.net to get a copy of this message | ||
On 11/8/05 11:38 PM, Richard Lynch wrote:
If you want to stuff NULL into something, and then use is_null() that makes sense. If you want to stuff NULL in there, and then use isset(), I'm not quite sure why you'd put NULL in there in the first place, but I don't rightly know what I'd expect isset() to return. Same for $a or $myarray['a']I know this is off-topic for this thread, but just as I see isset() misused (as in this case), I often see empty() misused. For example, when using empty(), the following all return TRUE: $a = 0; $b = NULL; $c = FALSE; $d = "0"; var_dump(empty($a)); var_dump(empty($b)); var_dump(empty($c)); var_dump(empty($d)); But, hey, is the value of the variable really empty (especially for $a and $d)? Likewise, if you're encountering a NULL value in a variable and you're checking it with isset(), then you need to consider why you're even getting a NULL value? You should filter your variables before you use them--even variables coming from $_SERVER. Remember, $_SERVER variables can be overwritten: $_SERVER['SERVER_NAME'] = 'Howdy Doody'; echo $_SERVER['SERVER_NAME']; So, make sure they're what you expect them to be. -- Ben Ramsey http://benramsey.com/