PHP __call vs method_exists

前端 未结 5 1008
花落未央
花落未央 2020-12-18 21:55

The Project I\'m working on contains something like a wrapper for call_user_func(_array) which does some checks before execution. One of those checks is method_exists (In Ca

5条回答
  •  离开以前
    2020-12-18 22:04

    __call handles calls to methods that don't exist. method_exists is an introspection method that checks the existence of a method.

    How can __call be determined to handle a method? I think you have to throw an exception manually in __call if doesn't handle your request and catch the exception in the code that would otherwise use method_exists. BadMethodCallException exists for this purpose.

提交回复
热议问题