php – function_exists每次都返回false

前端之家收集整理的这篇文章主要介绍了php – function_exists每次都返回false前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试检查一个函数是否存在但是我的if仍然是假的

我试着像这样调用函数,其中$function是函数名:

if (function_exists($this->module->$function))
{
    $this->module->$function($vars);
}
else
{
    echo 'no';
}

变量模块定义为应该调用函数的类:

$this->module = $module;
$this->module = new $this -> module;

我在这里错过了什么吗?
谢谢!

解决方法

可以搞清楚:
使用 method_exists()解决了我的问题

method_exists($this->module,$function)

我自己为可能遇到同样问题的人回答了这个问题!

猜你在找的PHP相关文章