国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

php 類自動載入的方法

2019-11-02 14:24:40
字體:
來源:轉載
供稿:網友

   在PHP5之前,各個PHP框架如果要實現類的自動加載,一般都是按照某種約定自己實現一個遍歷目錄,自動加載所有符合約定規則的文件的類或函數。 當然,PHP5之前對面向對象的支持并不是太好,類的使用也沒有現在頻繁。 我們來詳細探討下吧。

  php 類自動載入方法

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
探索宇宙[www.9-39.com/html/explore/]
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 <?php class inload { /** * 類自動載入,不需要由開發者調用 * * @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']; } }   /** * 注冊或取消注冊一個自動類載入方法 * * 該方法參考 Zend Framework * * @param string $class 提供自動載入服務的類 * @param boolean $enabled 啟用或禁用該服務 */ private function registerAutoload($class = 'Interpreter' , $enabled = true) { if (!function_exists('spl_autoload_register')) { throw new QException('spl_autoload 不存在這個PHP的安裝'); } if ($enabled === true) { spl_autoload_register(array($class, 'autoload')); } else { spl_autoload_unregister(array($class, 'autoload')); } }   /** * 析構函數 */ public function __destruct() { self::registerAutoload('Interpreter' , false); }

  以上所述就是本文的全部內容了,希望大家能夠喜歡。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 铅山县| 扬州市| 乌兰浩特市| 长治县| 正定县| 昂仁县| 合阳县| 凤台县| 金湖县| 汽车| 抚远县| 天镇县| 余江县| 新建县| 刚察县| 丹凤县| 湘潭县| 平罗县| 滕州市| 信宜市| 华宁县| 黄山市| 滨州市| 郧西县| 玉山县| 绩溪县| 铁岭县| 娄烦县| 雅江县| 凌云县| 株洲市| 肥城市| 综艺| 黔西县| 电白县| 剑川县| 永兴县| 三穗县| 齐河县| 淮北市| 和平区|