#49202 [Com]: php array documentation missing information on invalid key return value
| From: | niel dot archer at blueyonder dot co dot uk | Date: | Mon, 10 Aug 2009 07:37:58 +0000 |
| Subject: | #49202 [Com]: php array documentation missing information on invalid key return value | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2623@lists.php.net to get a copy of this message | ||
ID: 49202
Comment by: niel dot archer at blueyonder dot co dot uk
Reported By: receive at cprogramming dot ca
Status: Open
Bug Type: Documentation problem
Operating System: Web server
PHP Version: Irrelevant
New Comment:
Any default value would depend on context, as it does for all
variables. See
http://docs.php.net/manual/en/language.types.type-juggling.php
If, as it appears, you want to know if the key exists. It would be
better to test for that with the appropriate function ;-). Replace line
3 with:
3) if (!isset($a["testing_invalid_index"])){
Previous Comments:
------------------------------------------------------------------------
[2009-08-09 19:16:12] receive at cprogramming dot ca
Description:
------------
http://uk2.php.net/manual/de/language.types.array.php
There's no explanation in the online documentation of what value is
returned when you access an array with a key/index that doesn't exist.
For example, on line 3, I cannot use the documentation to tell me what
$a["testing_invalid_index"] will return to me. Does it return 0 or "" or
null or false, or does it give an error?
1) $a[] = array();
2) $a["sdfads"] = "booger";
3) if ($a["testing_invalid_index"] == false){
4) echo "Something";
5) }
Reproduce code:
---------------
---
From manual page: language.types.array
---
Expected result:
----------------
Documentation should indicate how an expression containing an array
with an invalid key/index is evaluated.
Actual result:
--------------
Documentation is missing information on how an expression containing an
array with an invalid key/index is evaluated.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49202&edit=1