PHP runtime class modification

后端 未结 3 403
猫巷女王i
猫巷女王i 2020-12-09 22:17

So I want to be able to add/remove class methods at runtime. Before you tell me that\'s horrible pratice in oop, it might be, but I don\'t really care. The reason I want to

3条回答
  •  被撕碎了的回忆
    2020-12-09 22:40

    PHP doesn't allow this. It may be a dynamic language in other respects, but the class system is deliberately restrictive. You can either install the runkit extension, which changes the language to allow mocking about with classes at runtime (But then you aren't using plain PHP anymore), or you can use the magic-methods to simulate it.

提交回复
热议问题