Yii引入PHPExcel修改其自动加载方法

修改PHPEXCEL目录下的Autoload.php这个文件,在每次使用PHPExcel的类时关闭Yii的自动加载类,否则的话会因为加载规则的不一致(如yii一般要求类的名字必须是xxController,方法要是actionXXX,而PHPExcel是xx_xxx_xxxx)而起冲突报错。

[php] view plaincopy
spl_autoload_unregister(array('YiiBase','autoload')); // 取消自动加载 ,就不会报错了
PHPExcel_Autoloader::Register(); 
//As we always try to run the autoloader before anything else, we can use it to do a few 
//simple checks and initialisations 
PHPExcel_Shared_ZipStreamWrapper::register(); 
// check mbstring.func_overload 
if (ini_get('mbstring.func_overload') & 2) { 
  throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).'); 
} 
PHPExcel_Shared_String::buildCharacterSets(); 
spl_autoload_register(array('YiiBase','autoload')); //重新自动加载

 

原文地址:https://www.cnblogs.com/zwue/p/4522020.html