On Mar 27, 2010, at 3:59 PM, Bharat Nagwani wrote:
> I might have missed earlier emails. How about this?
>
> $myLongNameObject = new myLongNameObject {
> property1: '11111',
> property2: '22222',
> property3: '33333',
> property4: '44444',
> property5: '55555',
> };
>
> Can we avoid the new as well like in Javascript?
>
> $myLongNameObject = {
> property3: 'xyz',
> property4: 'abc',
> property5: 5,
> property6: {
> a: 1
> }
> };
Except that "new myLongNameObject" and { } are not the same, your latter syntax — just
as in JavaScript — would
yield an anonymous object, essentially the same as "new stdClass" :)
You could just as easily do:
$myLongNameObject = (object) array (
'property3' => 'xyz',
'property4' => 'abc',
'property5' => (object) array (
'a' => 1
)
);