Re: object literals
| From: | Tom Worster | Date: | Fri, 01 May 2009 15:19:07 +0000 |
| Subject: | Re: object literals | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-292193@lists.php.net to get a copy of this message | ||
On 5/1/09 4:54 AM, "Richard Heyes" <richard@php.net> wrote:
> Hi,
>
>> $x = (object) array('a'=>1, 'b'=>3, ...);
>>
>> which works but isn't very lovely. it's neater in, for example, javascript.
>
> Well, you could wrap it up in a function to make it a bit lovelier. Eg:
>
> $foo = createObject(array('key' => 'value'));
>
> It's not great, but PHP doesn't have a object literal syntax AFAIK.
thanks. i really wanted to confirm that it's absent from the language. i've
been unsure for years if it's somewhere in the manual and i just can't find
it.