最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php 類自動載入的方法

 更新時間:2015年06月03日 12:25:26   投稿:hebedich  
在PHP5之前,各個PHP框架如果要實現(xiàn)類的自動加載,一般都是按照某種約定自己實現(xiàn)一個遍歷目錄,自動加載所有符合約定規(guī)則的文件的類或函數(shù)。 當(dāng)然,PHP5之前對面向?qū)ο蟮闹С植⒉皇翘茫惖氖褂靡矝]有現(xiàn)在頻繁。 我們來詳細(xì)探討下吧。

php 類自動載入方法

<?php
class inload 
{
/**
   * 類自動載入,不需要由開發(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'];
    }
  }
   
  /**
   * 注冊或取消注冊一個自動類載入方法
   *
   * 該方法參考 Zend Framework
   *
   * @param string $class 提供自動載入服務(wù)的類
   * @param boolean $enabled 啟用或禁用該服務(wù)
   */
  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'));
    }
  }
   
  /**
  * 析構(gòu)函數(shù)
  */
  public function __destruct()
  {
    self::registerAutoload('Interpreter' , false);
  }  

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

相關(guān)文章

最新評論

红河县| 双鸭山市| 伊春市| 泸定县| 南丰县| 平和县| 麦盖提县| 华蓥市| 和林格尔县| 澳门| 龙山县| 杭州市| 黑河市| 乡宁县| 石首市| 南阳市| 黔西县| 长岭县| 沐川县| 甘洛县| 寿光市| 密云县| 虹口区| 贵德县| 安塞县| 宜春市| 五家渠市| 乌鲁木齐市| 东光县| 全南县| 棋牌| 高要市| 宜川县| 阿拉尔市| 朝阳区| 通山县| 故城县| 双鸭山市| 仙居县| 潜山县| 义乌市|