Is it possible to extend a class dynamically?

前端 未结 8 1342
耶瑟儿~
耶瑟儿~ 2020-12-05 10:09

I have a class which I need to use to extend different classes (up to hundreds) depending on criteria. Is there a way in PHP to extend a class by a dynamic class name?

8条回答
  •  无人及你
    2020-12-05 10:36

    Yes. I like the answer with eval, but a lot of people afraid of any eval in their code, so here's one with no eval:

提交回复
热议问题