简体   繁体   中英

PHPExcel not working php 5.2 AppServ

I am using php 5.2.6 in AppServ on a Windows machine and PHPExcel does not seem to work and produces no errors. I have error_reporting set to E_ALL.

On my Linux machine where I am using php 5.6 and using vagrant/homestead the same code works just fine.

Here is my code: http://pastebin.com/6dJC8gaP

I added some echos to see where exactly it dies, and it seems to die on line 9. I had thought maybe it was an issue with php 5.2 and :: referencing, so I tried using the call_user_func, which also works on my php 5.6 but does not work on my php 5.2

http://php.net/manual/en/function.call-user-func.php

<?php

namespace Foobar;

class Foo {
    static public function test() {
        print "Hello world!\n";
    }
}

call_user_func(__NAMESPACE__ .'\Foo::test'); // As of PHP 5.3.0
call_user_func(array(__NAMESPACE__ .'\Foo', 'test')); // As of PHP 5.3.0

?>

Per page:

Quote:

In PHP v5.2, you /can/ use call_user_func(array($this, 'parent::SOME_FUNCTION')).

If you don't have custom __autoload() function, you are good to go.

If you do have custom __autoload(), you need to make it `parent' aware. Something like:

Rationale: PHP 5.2 surprisingly tries to autoload a class named 'parent'. However, if you don't do anything in __autoload() for the 'parent' class, it'll work just fine.

In PHPExcel/Settings.php there are two references to libxml_disable_entity_loader function.

That function is not available until php 5.2.11, and the @ in front of it was causing a silent error.

I did as they suggested and wrapped that function in function_exist checks. Everything works fine now.

Reference: https://github.com/PHPOffice/PHPExcel/issues/339

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM