#33230 [NEW]: Array() attepts comma before the closing ) and it is not mentioned

From: Date: Fri, 03 Jun 2005 11:31:02 +0000
Subject: #33230 [NEW]: Array() attepts comma before the closing ) and it is not mentioned
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-79842@lists.php.net to get a copy of this message
From:             phpbug at munaw dot com
Operating system: windows 2000
PHP version:      4.3.11
PHP Bug Type:     Arrays related
Bug description:  Array() attepts comma before the closing ) and it is not mentioned

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 bug report at http://bugs.php.net/?id=33230&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33230&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33230&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33230&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33230&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33230&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33230&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33230&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33230&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33230&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33230&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=33230&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=33230&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33230&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33230&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33230&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33230&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33230&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33230&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33230&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33230&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#79842) next »