1、PHP判断系统函数或自己写的函数是否存在
if(function_exists('curl_init')){ curl_init(); }else{ echo 'not function curl_init'; }
2、PHP判断类是否存在
bool class_exists ( string $class_name [, bool $autoload = true ] ) 检查一个类是否已经定义,一定以返回true,否则返回false,例如:
if(class_exists('MySQL')){ $myclass=new MySQL(); }
3、PHP判断类里面的某个方法是否已经定义
bool method_exists ( mixed $object , string $method_name ) 检查类的方法是否存在,例如:
$directory=new Directory; if(!method_exists($directory,'read')){ echo '未定义read方法!'; }
© 版权声明
特别声明:该文观点仅代表作者本人,"遇见科技圈"仅提供信息存储空间服务,如需转载、摘编请取得原作者授权。
THE END