PHP This function checks whether or not the given class has been defined.
php揁欑▼鍒ゆ柇绫画槸钖﹀瓨鍦ㄥ嚱鏁?class_exists
//bool class_exists ( string $class_name [, bool $autoload = true ] )
// his function checks whether or not the given class has been defined.
//杩洿洖true锛屽鏋渃lass_name鄄竴涓畾涔夌殑竫麴钖﹀垯杩洿洖false銆?br /> //瀹簰緥
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();
}