PHP __call vs method_exists

前端 未结 5 1017
花落未央
花落未央 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:17

    If you are really sure that _call always has a fall-back, you can do:

    if (method_exists($this, $method_name) || method_exists($this, '__call')) {
      // Call of the method
    }
    

提交回复
热议问题