#46251 [Asn->Csd]: Array type documentation, error in example

From: Date: Wed, 05 Nov 2008 22:01:20 +0000
Subject: #46251 [Asn->Csd]: Array type documentation, error in example
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1395@lists.php.net to get a copy of this message
ID: 46251 Updated by: torben@php.net Reported By: php at pengi dot se -Status: Assigned +Status: Closed Bug Type: Documentation problem PHP Version: Irrelevant Assigned To: torben 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: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#1395) next »