php判断类是否存在函数class_exists用法分析
本文实例分析了php判断类是否存在函数class_exists用法。分享给大家供大家参考。具体如下:
如果我们要判断一个类是不是可以用,可以先使用class_exists函数来判断一下,下面来看几个例子。
bool class_exists ( string $class_name [, bool $autoload = true ] )
此功能是否给定的类被定义检查。this function checks whether or not the given class has been defined.
返回true,如果class_name是一个定义的类,否则返回false。
实例如下:
{
include($class . '.php');
// check to see whether the include declared the class
if (!class_exists($class, false)) {
trigger_error("unable to load class: $class", e_user_warning);
}
}
if (class_exists('myclass')) {
$myclass = new myclass();
}
希望本文所述对大家的PHP程序设计有所帮助。
- php通过function_exists检测函数是否存在的方法
- php使用function_exists判断函数可用的方法
- php !function_exists("T7FC56270E7A70FA81A5935B72EACBE29"))代码解密
- 解析php函数method_exists()与is_callable()的区别
- php数组函数序列之in_array() - 查找数组中是否存在指定值
- php数组函数序列之in_array() 查找数组值是否存在
- php数组函数序列之array_key_exists() - 查找数组键名是否存在
- php file_exists 检查文件或目录是否存在的函数
- PHP 判断常量,变量和函数是否存在
- php判断某个方法是否存在函数function_exists (),method_exists()与is_callable()区别与用法解析
相关文章
Linux下安装Memcached服务器和客户端与PHP使用示例
这篇文章主要介绍了Linux下安装Memcached服务器和客户端与PHP使用,结合实例形式分析了Linux环境下的Memcached服务器和客户端安装命令、注意事项及php相关使用技巧,需要的朋友可以参考下2019-04-04
windows下PHP_intl.dll正确配置方法(apache2.2+php5.3.5)
配置php_intl模块总是加载失败,在这找到了解决方法2014-01-01


最新评论