Is there a special object initializer construct in PHP like there is now in C#?

vaviqeboge

New Member
I know that in C# you can nowadays do:\[code\]MyObject a = new MyObject(){ Property1 = 1, Property2 = 2};\[/code\]Is there something like that in PHP too? Or should I just do it through a constructor or through multiple statements;\[code\]$a = new MyObject(1, 2);$a = new MyObject();$a->property1 = 1;$a->property2 = 2;\[/code\]If it is possible but everyone thinks it's a terrible idea, I would also like to know.PS: the object is nothing more than a bunch of properties.
 
Back
Top