|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75426 "Cannot use empty array elements" reports wrong position
Submitted: 2017-10-24 12:20 UTC Modified: 2019-01-02 10:39 UTC
Avg. Score:4.0 ± 0.9
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:4 (80.0%)
From: Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 7.2.0RC4 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
19 + 1 = ?
Subscribe to this entry?

 [2017-10-24 12:20 UTC]
If there is a syntax error because there are two consecutive commas in an array, a fatal error is reported:

  PHP Fatal error:  Cannot use empty array elements in arrays in file.php on line 3

The problem is that the line reported is the start of the array definition, not the line at which the error actually is.

This makes it very hard to debug array definitions of 100 lines length.

See and

Test script:
$a = [

Expected result:
Line 4 should be reported.

Actual result:
Line 3 is reported.


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-23 11:06 UTC] andrew dot nester dot dev at gmail dot com
Thanks for pointing this issue! I've just added CR implementing this.
 [2019-01-02 10:39 UTC]
I've committed a partial fix for this issue at It doesn't actually change anything for the case shown here, but if the array is larger, it will now point to the element before the stray comma.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Mar 22 15:03:36 2023 UTC