阅读背景:

php 类自动载入的方法

来源:互联网 

!--NEWSZW_HZH_BEGIN--

php 类主动载入办法

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

<?php
class in




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: