Re: Type of form element

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx | http://www.synchromedia.co.uk

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux