spl_autoload_register更改框架文件引用模式

今天单点登陆要用到 spl_autoload_register,但是YII的Yii::autoload在包含失败的时候会抛异常,就不会执行(spl_autoload_call)其他spl_autoload_register的了, 于是想到了一个解决的办法,就是删除所有的spl_autoload_functions  然后把 单点登录的 autoload函数加上,最后再加上 Yii原有的autoload函数 即可。

// set up __autoload
if (function_exists('spl_autoload_register')) {
    if (!(spl_autoload_functions()) || !in_array('CAS_autoload', spl_autoload_functions())) {
        $functions = spl_autoload_functions();
        foreach($functions as $function) {
            spl_autoload_unregister($function);
        }
        spl_autoload_register('CAS_autoload');
        foreach($functions as $function) {
            spl_autoload_register($function);
        }
    }
}
原文地址:https://www.cnblogs.com/sailrancho/p/4561042.html