|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [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: Fri Dec 01 21:01:27 2023 UTC