Phpexcel automatic loading conflicts with other frameworks _ PHP Tutorial

Source: Internet
Author: User
Tags autoloader spl
The automatic loading of phpexcel conflicts with other frameworks. The automatic loading of phpexcel conflicts with other frameworks and always wants to use PHPEXCEL. this project has encountered. However, the pitfalls have also come out. In phpexcel's Autoloader. php, the automatic loading of publicstaticfunctionRe phpexcel conflicts with other frameworks.
I always wanted to use PHPEXCEL. this project has been encountered. However, the pitfalls have also come out. In 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'));    }

This is in conflict with the automatic loading of existing frameworks. To solve this problem, only one of them can be changed. I chose phpexcel because other projects in the framework are automatically loaded and cannot change the framework for one function.

The method found on the internet is to delete it to 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;}

Ghost always wanted to use PHPEXCEL. this project encountered. However, the pitfalls have also come out. In Autoloader. php of phpexcel, public static function Re...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.