Re: [RFC] Bare Name Array
| From: | Rowan Collins | Date: | Sun, 01 Jun 2014 20:09:41 +0000 |
| Subject: | Re: [RFC] Bare Name Array | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-74684@lists.php.net to get a copy of this message | ||
On 01/06/2014 20:56, Andrea Faulds wrote:
To look at another popular language, it’s interesting Perl does the opposite to PHP: Perl: %hash = ( ‘key’, ‘value’ );That's not really "the opposite". IIRC, the => is considered to be "syntactic sugar" for the ",". The quotes are optional in both cases. I've always thought of PHP's arrays as mostly like Perl's arrays in syntax - they always use [] for access, never {}. They've then borrowed the => for key-value association from Perl's hashes, or somewhere else. But in general, I think it's an exaggeration to say that "PHP is Perl-inspired"; I think there were many inspirations for PHP as it evolved - it was never "a better Perl", or "a better C", or anything like that. Regards, -- Rowan Collins [IMSoP]PHP: $hash = [ ‘key’ => ‘value’ ]Perl: %hash = ( key => ‘value’ );PHP: $hash = [ key: ‘value’ ]While Perl’s => is for unquoted strings, PHP’s is for quoted strings, which is bizarre considering PHP is Perl-inspired. :)