Re: Arrays: Comma at end?

From: Date: Wed, 08 Feb 2012 02:13:09 +0000
Subject: Re: Arrays: Comma at end?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-316551@lists.php.net to get a copy of this message
On Wed, Feb 8, 2012 at 4:10 AM, Ashley Sheridan <ash@ashleysheridan.co.uk> wrote: > On Tue, 2012-02-07 at 11:50 -0800, Micky Hulse wrote: > >> Was there ever a time when having a comma at the end of the last array >> element was not acceptable in PHP? ... > It's fine in PHP, and some coding practices actually encourage it, for > example: ... > > It's easy to add and remove elements without making sure you have to > check the trailing comma. It's also OK in Javascript to use the trailing > comma, as long as you don't mind things not working on IE, which is the > only browser that has issues with it. As far as PHP goes though, it's > fine. I believe this behavior was inherited from Perl. I used Perl before I used PHP and it was considered a feature for exactly the reason Ash gave. I think that problems with Perl may have originally inspired the creation of PHP, at least in part. But they kept the good parts. This is just my perception. To confirm it, I'd have to ask our BDFL :) -- Vince Aggrippino a.k.a. Ghodmode http://www.ghodmode.com > -- > Thanks, > Ash > http://www.ashleysheridan.co.uk > >

« previous php.general (#316551) next »