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
http://www.bkjia.com/PHPjc/1061539.htmlwww.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