Re: Type of form element

From: Date: Tue, 01 Nov 2005 00:15:40 +0000
Subject: Re: Type of form element
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-224906@lists.php.net to get a copy of this message
Marcus Bointon wrote:
Given $myarray['a'] = NULL, isset($myarray[a']) returns false.
Yes, I think we've established that. I'm sure Richard and I were both well aware of this fact, but just in case we weren't, I think we can safely assume we are by now. :-)
You're saying that therefore, $myarray['a'] does not exist
Well, I have the same opinion that isset() does - if a variable is set to NULL, it may as well not be set. I understand and appreciate the way PHP works and frequently rely upon its friendly behavior. If I really care to know whether something is NULL (which I rarely do), I can always use is_null(). Of course, none of this applies to the present topic, because NULL is not a string. In previous replies, I've provided methods that you can use to distinguish between NULL, the empty string, 0, etc. There's also a table at the top of this cheat sheet that you might find helpful: http://www.blueshoes.org/en/developer/php_cheat_sheet (Notice that is_null() and isset() are boolean opposites.) Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/

« previous php.general (#224906) next »