如何在CentOS上的PHP 5.3中激活ZipArchive类

问题描述:

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?

我在文档我应该只使用”--enable-zip“参数编译PHP 5.3.3,但这不起作用。 我这样做但 class_exists('ZipArchive') code>总是返回 false code>。 我接下来该怎么办? p> div>

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