现在的位置: 首页 > 问答 > 正文

Check Function exists or not in PHP

2016年10月06日 问答 ⁄ 共 497字 ⁄ 字号 暂无评论

I wants to check if function exists or not. I am using function_exists() to check.

$func = $_GET['function'];
$func();
if(function_exists('func'))
{
    echo "Exists";
}
else
{
    echo "Invalid Function name called";
}

Okay now I have a function called register and I am calling it like this:

www.example.com/index.php?function=register

Okay it is working fine,because that function do exists.
but if,

www.example.com/index.php?function=registerssss

It gives me this error:

Call to undefined function registerssss()

I wants to print my custom error as I have posted above.
Any Solution.?

给我留言

您必须 [ 登录 ] 才能发表留言!

×