时间:2021-07-01 10:21:17 帮助过:1人阅读
bool class_exists ( string $class_name [, bool $autoload = true ] )
此功能是否给定的类被定义检查,返回true,如果class_name是一个定义的类,否则返回false.
php实例代码如下:
if (class_exists('myclass')) {
$myclass = new myclass();
}
function __autoload($class)
{
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();
}//开源代码phpfensi.com