首頁  >  文章  >  後端開發  >  php鍒ゆ柇绫绘槸鍚﹀瓨鍦ㄥ嚱鏁?class_exists_PHP鏁欑▼ | 甯涔嬪

php鍒ゆ柇绫绘槸鍚﹀瓨鍦ㄥ嚱鏁?class_exists_PHP鏁欑▼ | 甯涔嬪

WBOY
WBOY原創
2016-07-20 11:01:251068瀏覽

php鍒ゆ柇绫绘槸鍚﹀瓨鍦ㄥ嚱鏁?class_exists//bool class_exists ( string $class_name [, bool $autoload = true ] )//姝ゅ姛鑳芥槸鍚︾粰瀹氱殑绫昏瀹氫箟妫€鏌ャ€俆his 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();
}


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445448.htmlTechArticlephp鍒ゆ柇绫绘槸鍚﹀瓨鍦ㄥ嚱鏁?class_exists//bool class_exists ( string $class_name [, bool $autoload = true ] )//姝ゅ姛鑳芥槸鍚︾粰瀹氱殑绫昏瀹氫箟妫€鏌ャ€俆his function checks w...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn