#33230 [Opn->Bgs]: Array() attepts comma before the closing ) and it is not mentioned
ID: 33230
Updated by: tony2001@php.net
Reported By: phpbug at munaw dot com
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: windows 2000
PHP Version: 4.3.11
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
"Having a trailing comma after the last defined array entry, while
unusual, is a valid syntax."
http://www.php.net/manual/en/function.array.php
Previous Comments:
------------------------------------------------------------------------
[2005-06-03 13:31:02] phpbug at munaw dot com
Description:
------------
Hello,
As I know, array() should not accept comma after the last element but
it does and var_export generates it the same way. If it accepts this
syntax, it could be mentioned in the documentation.
Reproduce code:
---------------
echo phpversion()."\n";
$array = array(
'1' => 'one',
'2' => 'two',
'3' => 'three', // <-comma
);
var_export($array);
Expected result:
----------------
Parse error saying unexpected '(' or something like this.
Actual result:
--------------
4.3.11
array (
1 => 'one',
2 => 'two',
3 => 'three',
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33230&edit=1
Thread (3 messages)