#46251 [Opn]: Array type documentation, error in example
| From: | php at pengi dot se | Date: | Wed, 08 Oct 2008 10:55:37 +0000 |
| Subject: | #46251 [Opn]: Array type documentation, error in example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1192@lists.php.net to get a copy of this message | ||
ID: 46251
User updated by: php at pengi dot se
Reported By: php at pengi dot se
Status: Open
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
This also applies to the next section of the example.
$b = array();
Previous Comments:
------------------------------------------------------------------------
[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