#46251 [WFx->Asn]: Array type documentation, error in example
| From: | danbrown@php.net | Date: | Wed, 05 Nov 2008 17:39:43 +0000 |
| Subject: | #46251 [WFx->Asn]: Array type documentation, error in example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1393@lists.php.net to get a copy of this message | ||
ID: 46251
Updated by: danbrown@php.net
Reported By: php at pengi dot se
-Status: Wont fix
+Status: Assigned
Bug Type: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: torben
Previous Comments:
------------------------------------------------------------------------
[2008-10-08 10:55:36] php at pengi dot se
This also applies to the next section of the example.
$b = array();
------------------------------------------------------------------------
[2008-10-07 23:45:51] php at pengi dot se
Description:
------------
First example under section Examples in documentation for Array type
says, that creating an array with array(initial value) is the same as
writing:
$a[key] = value;
$a[key] = value;
$a[key] = value;
but missing initialization of the variable.
This may also be a security issue for people using this way of
initialization and also are using register_globals.
What should be added to the example is:
$a = array();
URL to related documentation page:
http://php.net/manual/en/language.types.array.php
Reproduce code:
---------------
// this
$a = array( 'color' => 'red',
'taste' => 'sweet',
'shape' => 'round',
'name' => 'apple',
4 // key will be 0
);
// is completely equivalent with
$a['color'] = 'red';
$a['taste'] = 'sweet';
$a['shape'] = 'round';
$a['name'] = 'apple';
$a[] = 4; // key will be 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46251&edit=1