function_exists()不工作codeigniter
问题描述:
我想检查一个函数是否存在并执行处理。function_exists()不工作codeigniter
我通过检查:
if(function_exists("create_offerlovit_template_data"))
{
echo "function exists";
}
else
{
echo "function not exists";
}
我具备的功能:
public function create_offerlovit_template_data($update,$shop_id)
{
}
的功能存在,但始终打印 '功能不存在'。这是为什么发生?我该如何正确使用function_exists
。
答
您正在寻找http://www.php.net/manual/en/function.method-exists.php。
function_exists是唯一的功能。
例子:
method_exists($instance, "create_offerlovit_template_data");
答
public function create_offerlovit_template_data($update,$shop_id){}
这看起来像一个类的方法,而不是一个 “独立”?功能(坏术语那里我知道了),
我相信你正在寻找这个method_exists
答
你检查功能的存在,但“公共职能” - 是一种方法。 使用“method_exists()”。
答
,以检查是否在某个对象存在一个特定的方法,尝试使用method_exists()函数:
资源(link)
你可以尝试
if (method_exists($this,$method)) {
// if true
} else {
// if false
}
的http:// ellislab。 COM /论坛/ viewthread/82837 /#416766 – 2013-04-09 12:40:15