Re: Type of form element

From: Date: Mon, 31 Oct 2005 20:53:15 +0000
Subject: Re: Type of form element
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-224899@lists.php.net to get a copy of this message
On 31 Oct 2005, at 17:55, Richard Lynch wrote:
You're wrong.
No. You're just missing what I'm on about. I'll agree it's very dull.
isset() does not, under any circumstances, create an index nor a variable.
Quite right; I never said it did.
Its entire purpose *IS* to tell you if something has been set to a value. That's why it's CALLED "isSet"
But that's not the question you're using isset to answer. You just want to know if something exists - you probably don't even care what its value is. Take apart this operation: $a = isset($myarray['a']); Implicit in this simple line is a 'hidden' step which is to look up the index 'a' in $myarray to get its value before testing if it is set or not. The issue I have is that that step's existence is being overlooked. That line could also be written: $a = !is_null($myarray['a']); Either way, if $myarray['a'] does not exist, its value will be regarded as null (and as such, isset and !is_null would give correct results as a consequence of this convenient side-effect), but I would also fully expect to receive an undefined index notice as you have explicitly looked up an array index that does not exist. If you used other functions the same way you're using isset, you would see nothing wrong with this: $myarray = array(); print $myarray['a']; but I would hope that you would have a problem with that. Why treat isset differently? Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture marcus@synchromedia.co.uk | http://www.synchromedia.co.uk

« previous php.general (#224899) next »