美文网首页
php 判断 函数 类 方法是否存在

php 判断 函数 类 方法是否存在

作者: panw3i | 来源:发表于2018-01-04 10:51 被阅读59次

判断函数

if(function_exists('curl_init')){
    curl_init();
}else{
    echo 'not function curl_init';
}

判断类

if(class_exists('MySQL')){
    $myclass=new MySQL();
}

判断方法

$directory=new Directory;
if(!method_exists($directory,'read')){
    echo '未定义read方法!';
}

相关文章

网友评论

      本文标题:php 判断 函数 类 方法是否存在

      本文链接:https://www.haomeiwen.com/subject/qttrnxtx.html