#49202 [Opn->Csd]: php array documentation missing information on invalid key return value
| From: | torben@php.net | Date: | Wed, 26 Aug 2009 06:34:31 +0000 |
| Subject: | #49202 [Opn->Csd]: 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-2661@lists.php.net to get a copy of this message | ||
ID: 49202
Updated by: torben@php.net
Reported By: receive at cprogramming dot ca
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Web server
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2009-08-26 06:34:01] svn@php.net
Automatic comment from SVN on behalf of torben
Revision: http://svn.php.net/viewvc/?view=revision&revision=287729
Log: Clarified what will happen when attempting to access an undefined
array index.
Addresses Bug #49202.
------------------------------------------------------------------------
[2009-08-22 09:22:53] torben@php.net
The resultant value is the same as for checking any undefined
variable--it's null. That's the only value it can logically have; any
other type would indicate a known value, which would be nonsense since
you cannot know the type of something which does not exist.
------------------------------------------------------------------------
[2009-08-10 07:37:57] niel dot archer at blueyonder dot co dot uk
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"])){
------------------------------------------------------------------------
[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