《PHP應(yīng)用:php 類自動(dòng)載入的方法》要點(diǎn):
本文介紹了PHP應(yīng)用:php 類自動(dòng)載入的方法,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
PHP應(yīng)用php 類自動(dòng)載入辦法
PHP應(yīng)用 <?php class inload { /** * 類自動(dòng)載入,不需要由開發(fā)者調(diào)用 * * @param string $class 類文件 */ private function autoload( $class ) { if( empty($class) ) { throw new QException('加載文件不存在'.$class); } else { require _SPRING_.'/_Core/SpringMap.php'; //框架地圖 if(! file_exists( $source[$class]['file'] ) ) { throw new QException('加載文件不存在'.$class); } require $source[$class]['file']; } } /** * 注冊(cè)或取消注冊(cè)一個(gè)自動(dòng)類載入辦法 * * 該辦法參考 Zend Framework * * @param string $class 提供自動(dòng)載入服務(wù)的類 * @param boolean $enabled 啟用或禁用該服務(wù) */ private function registerAutoload($class = 'Interpreter' , $enabled = true) { if (!function_exists('spl_autoload_register')) { throw new QException('spl_autoload 不存在這個(gè)PHP的安裝'); } if ($enabled === true) { spl_autoload_register(array($class, 'autoload')); } else { spl_autoload_unregister(array($class, 'autoload')); } } /** * 析構(gòu)函數(shù) */ public function __destruct() { self::registerAutoload('Interpreter' , false); }
PHP應(yīng)用以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡.
維易PHP培訓(xùn)學(xué)院每天發(fā)布《PHP應(yīng)用:php 類自動(dòng)載入的方法》等實(shí)戰(zhàn)技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養(yǎng)人才。
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/10406.html