function_exists() 函数用以判断函数是否被定义过,语法如下:
[Plain Text] 纯文本查看 复制代码 bool function_exists ( string $function_name )
如果被定义过,函数返回 TRUE;否则返回 FALSE 。
测试代码:
[PHP] 纯文本查看 复制代码 <?php
function myfunc1() {
echo "hello myfunc1";
}
if (function_exists('myfunc1'))
echo "myfunc1() is defined." . "<br>";
else
echo "myfunc1() is not fefine." . "<br>";
if (function_exists('myfunc2'))
echo "myfunc2() is defined." . "<br>";
else
echo "myfunc2() is not fefine." . "<br>";
?>
运行输出:myfunc1() is defined.
myfunc2() is not fefine. |