Maison  >  Article  >  développement back-end  >  phpexcel的自动加载与其他框架有冲突_PHP教程

phpexcel的自动加载与其他框架有冲突_PHP教程

WBOY
WBOYoriginal
2016-07-12 09:07:21971parcourir

phpexcel的自动加载与其他框架有冲突

一直想用PHPEXCEL,这次这个项目遇到了。然而坑也出来了。phpexcel的Autoloader.php里面
 
public static function Register() {
   /* if (function_exists('__autoload')) {
        //    Register any existing autoloader function with SPL, so we don't get any clashes
        spl_autoload_register('__autoload');
    }
    //    Register ourselves with SPL
    return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
    }

 

 
与以现有框架的自动加载有冲突了。为了解决这个问题,只可以改其中一个,我选择了phpexcel,因为框架的其他项目都用本身的自动加载,不能为了一个功能改动框架本身。
从网上找到了方法,就是删到原来的,用这个新的就可以解决了。
 
public static function Register() {
   /* if (function_exists('__autoload')) {
        //    Register any existing autoloader function with SPL, so we don't get any clashes
        spl_autoload_register('__autoload');
    }
    //    Register ourselves with SPL
    return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));*/
    $functions = spl_autoload_functions();
    foreach ( $functions as  $function)
        spl_autoload_unregister($function);
    $functions = array_merge(array(array('PHPExcel_Autoloader','Load')),$functions);
    foreach ( $functions as $function)
        $x = spl_autoload_register($function);
    return $x;
}

 

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1061539.htmlTechArticlephpexcel的自动加载与其他框架有冲突 一直想用PHPEXCEL,这次这个项目遇到了。然而坑也出来了。phpexcel的Autoloader.php里面 public static function Re...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn