Home > Backend Development > PHP Tutorial > The automatic loading of phpexcel conflicts with other frameworks_PHP tutorial

The automatic loading of phpexcel conflicts with other frameworks_PHP tutorial

WBOY
Release: 2016-07-12 09:07:21
Original
1030 people have browsed it

The automatic loading of phpexcel conflicts with other frameworks

I have always wanted to use PHPEXCEL, and this time I encountered it in this project. However, the pit has also emerged. Inside Autoloader.php of 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'));
    }
Copy after login

Conflicts with automatic loading of existing frameworks. In order to solve this problem, only one of them can be changed. I chose phpexcel, because other projects in the framework use their own automatic loading, and the framework itself cannot be changed for a function.
I found a way from the Internet, which is to delete the original one and use this new one to solve the problem.
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;
}
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1061539.htmlTechArticleThe automatic loading of phpexcel conflicts with other frameworks. I have always wanted to use PHPEXCEL, but this time I encountered it in this project. However, the pit has also emerged. Public static function Re...
in Autoloader.php of phpexcel
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template