开发者

How-to activate the ZipArchive class in PHP 5.3 on CentOS

开发者 https://www.devze.com 2023-01-27 22:16 出处:网络
I read on the documentation I should only compile PHP 5.3.3 with \"--enable-zip\" parameter, but this doesn\'t work. I did this but class_exists(\'ZipArchive\') always return 开发者_如何学编程false. W

I read on the documentation I should only compile PHP 5.3.3 with "--enable-zip" parameter, but this doesn't work. I did this but class_exists('ZipArchive') always return 开发者_如何学编程false. What should I do next?


Have you tried installing ZipArchive using pecl?

$ pecl install zip

then add extension=zip.so to your php.ini


Make sure that the Zip class is being loaded by your server by,

  1. Write a quick phpinfo(); script and check if Zip is enabled; and
  2. If it isn't, you can check the /etc/php.d/zip.ini file to make sure that the zip.so file is being loaded when PHP kicks off.
  3. As you can see here make sure you are using the class_exists function correctly for your version of PHP.

[ >= PHP 5.3]

If you are checking if a class exists that is in a specific namespace then you have to pass in the full path to the class:

echo (class_exists("com::richardsumilang::common::MyClass")) ? "Yes" : "No";

Hope that helps.


pecl install zip: compilation terminated. make: *** [php_zip.lo] Error 1 ERROR: `make' failed

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号