This example describes a workaround for PHP using the ziparchive hint fatal error:class ziparchive not found in. Share to everyone for your reference. Specifically as follows:
Ziparchive is a compression and decompression function that comes with PHP, and it's a matter of course today when you use the new ziparchive to create a zip file, you get a hint fatal error:class ziparchive not found in error, Interested friends together to see how to solve.
The test code is as follows:
Copy Code code as follows:
PHP uncompressed file (Zip)
function Unzip_file ($file, $destination) {
$zip = new Ziparchive ();
Open compressed file
if ($zip->open ($file)!== TRUE) {
Die (' could not open archive ');
}
Create a file
$zip->extractto ($destination);
$zip->close ();
echo ' success ';
}
Unzip_file ("Htdocs.zip", "wenjianming");
Discovery during execution
Fatal error:class ' ziparchive ' not found in e:wwwqqdown.php to line 63
see this is not undefined, so small series Baidu search, the following explanation
The solution under Windows is:
1, in the php.ini file, will extension=php_zip.dll before the semicolon ";" Removal
Reboot the Apache server, and we'll try again to find out.
Add:
If it is a Linux system refer to the following method
There's no php_zip.dll this file under Linux.
You need to recompile PHP's Zip module. The specific installation method is as follows:
Copy Code code as follows:
Cd/usr/src
wget Http://pecl.php.net/get/zip
TAR-ZXVF zip
CD zip-1.x.x
Phpize
./configure
Make
sudo make install
It is possible to use the root permission when the make install command is last used, so sudo is recommended for running. After installation, the screen prompts for the location of the zip.so. Then record it, such as:/usr/local/lib/php/extensions/zip.so.
2, the use of root permissions to modify the php.ini (usually in the/usr/local/lib/folder, but depending on the original installation of PHP, you can through the phpinfo () to view):
Add extension =/usr/local/lib/php/extensions/zip.so, then also in php.ini file, change zlib.output_compression = off to Zlib.output_ compression = on;
3, in the end don't forget to restart Apache:apachectl restart;
Note: There are some friends on the website that say zlib.output_compression = off change to zlib.output_compression = on; I don't have any operations under windows that I don't see in the php.ini file, but it does make or extract files.
I hope this article will help you with your PHP program design.