3 ms·
It's been a long time since I did any PHP, but are trailing commas illegal? Normally, it seems like languages follow one of these two patterns, depending on wh
by tsuraan 15y ago
It's been a long time since I did any PHP, but are trailing commas illegal? Normally, it seems like languages follow one of these two patterns, depending on whether their syntax allows extraneous commas or not:
foo = [
'first',
'second',
'third',
]
or
foo = [ 'first'
, 'second'
, 'third'
]
The difference between those two examples and yours being that when you want to add a new entry, you only have to edit the line of the entry, rather than having to edit the line before the entry (to put in the comma) as well as the line that you care about. Just an idle question, really.
EDIT: pull unnecessary commentary
- jasonlotito 15y agoNo, trailing commas are not illegal. It's actually preferred. $a = array(1,2,3,); works just fine.