Can I instantiate a PHP class inside another class?

前端 未结 8 821
挽巷
挽巷 2020-12-08 03:57

I was wondering if it is allowed to create an instance of a class inside another class.

Or, do I have to create it outside and then pass it in through the constructo

8条回答
  •  离开以前
    2020-12-08 04:45

    It's impossible to create a class in another class in PHP. Creating an object(an instance of a class) in another object is a different thing.

提交回复
热议问题