Call private methods and private properties from outside a class in PHP

前端 未结 8 1883
离开以前
离开以前 2020-12-15 18:21

I want to access private methods and variables from outside the classes in very rare specific cases.

I\'ve seen that this is not be possible although introspection

8条回答
  •  清酒与你
    2020-12-15 19:04

    If you are able to added a method in the class where the method is defined, you can add method which uses the call_user_method() internally. This works also with PHP 5.2.x

    callprivate('somePrivateMethod');
    

提交回复
热议问题