#33230 [Opn->Bgs]: Array() attepts comma before the closing ) and it is not mentioned

From: Date: Fri, 03 Jun 2005 11:34:33 +0000
Subject: #33230 [Opn->Bgs]: Array() attepts comma before the closing ) and it is not mentioned
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-79843@lists.php.net to get a copy of this message
 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)

« previous php.bugs (#79843) next »