欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

php判断类是否存在函数 class_exists

shiping1 的头像

php判断类是否存在函数 class_exists

来源:   时间:2013-09-05 19:01:46   阅读数:5689
分享到:1

[导读] php判断类是否存在函数 class_exists bool class_exists ( string $class_name [, bool $autoload = true ] ) 此功能是否给定的类被定义检查。This function checks whether or not the gi

php判断类是否存在函数 class_exists//bool class_exists ( string $class_name [, bool $autoload = true ] )//此功能是否给定的类被定义检查。This function checks whether or not the given class has been defined.
 

php教程判断类是否存在函数 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。
//实例

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();
}

来自 http://www.php100.com/html/php/hanshu/2013/0905/4528.html
普通分类: