加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php 类自动载入的方法

发布时间:2020-12-12 20:54:43 所属栏目:PHP教程 来源:网络整理
导读:php 类自动载入方法 /** 注册或取消注册一个自动类载入方法 该方法参考 Zend Framework @param string $class 提供自动载入服务的类 @param boolean $enabled 启用或禁用该服务 */ private function registerAutoload($class = 'Interpreter',$enabled = tru

php 类自动载入方法

/**

  • 注册或取消注册一个自动类载入方法
  • 该方法参考 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);
    }

以上所述就是本文的全部内容了,希望大家能够喜欢。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读