Re: Object and Array Literals
| From: | Sean Coates | Date: | Sun, 05 Jun 2011 21:47:28 +0000 |
| Subject: | Re: Object and Array Literals | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52978@lists.php.net to get a copy of this message | ||
>> $foo = {
>> 'bar' : function(){
>> echo 'baz';
>> }
>> };
>>
>> $foo->bar();
>
> I guess it's not yet too late to surpass Perl in the front of obscurity...
Since the stuff to the right of the assignment operator (
: in this case) is valid PHP,
I don't see why this wouldn't be allowed if we adopt the {} syntax. It's not much
different from this, which is currently valid:
$foo = (object)array(
'bar' => function () {
echo 'baz';
}
};
S