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

后端 未结 4 1181
抹茶落季
抹茶落季 2020-12-17 08:33

I know that in C# you can nowadays do:

var a = new MyObject
{
    Property1 = 1,
    Property2 = 2
};

Is there something like that in PHP t

4条回答
  •  囚心锁ツ
    2020-12-17 09:28

    I suggest you use a constructor and set the variables you wish when initialising the object.

提交回复
热议问题