#19080 [Com]: Docs not clear on the diff between isset() and array_key_exists()
| From: | mvivino at avaya dot com | Date: | Fri, 03 Oct 2003 12:35:54 +0000 |
| Subject: | #19080 [Com]: Docs not clear on the diff between isset() and array_key_exists() | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969356498@lists.php.net to get a copy of this message | ||
ID: 19080
Comment by: mvivino at avaya dot com
Reported By: andrey at webgate dot bg
Status: Closed
Bug Type: Documentation problem
Operating System: All
PHP Version: 4.2.2
New Comment:
After being "bitten" by this one myself, I looked back at the
documentation more carefully, and of course this is correct behavior,
as noted in the thread above.
The one-line summary of the function's behavior is still (IMHO) wrong:
>> Returns TRUE if var exists; FALSE otherwise.
Simply rewriting this as:
>> Returns TRUE if var exists and is not set to NULL; FALSE otherwise.
would make the behavior crystal clear, and might save a few other folks
trouble in the future.
Previous Comments:
------------------------------------------------------------------------
[2002-08-28 12:25:00] kalowsky@php.net
There is an example in the docs explaining the difference between this
on the isset() page.
------------------------------------------------------------------------
[2002-08-23 19:20:27] andrey at webgate dot bg
Hello,
this code :
<?php
$a = array(1=>NULL);
var_dump($a);
var_dump(isset($a[1]));
var_dump(array_key_exists(1,$a));
?>
Produces this :
array(1) {
[1]=>
NULL
}
bool(false)
bool(true)
So for first time I see difference in the use of isset() and
array_key_exists(). Many users (including me till 1 one ago) believe
that they are equivalent and because isset() is shorter it is mostly
used.
Should be there any notice in the docs about this issue?
This code is correct and the bug report was inspired by note to do this
by jmcastagnetto.
Regards,
Andrey
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19080&edit=1