Php prompts Fatalerror: ClassZipArchivenotfoundin using ZipArchive

Source: Internet
Author: User
Tags ziparchive
This article mainly introduces the solution for php to use ZipArchive to prompt Fatalerror: ClassZipArchivenotfoundin, which is a problem frequently encountered when ZipArchive is used, for more information about how to use ZipArchive to prompt Fatal error: Class ZipArchive not found in, see the example in this article. Share it with you for your reference. The details are as follows:

ZipArchive is a built-in compression and decompression function of php. if we use new ZipArchive to create a zip file today, the following error occurs: Fatal error: Class ZipArchive not found in, if you are interested, let's take a look at the solution.

The test code is as follows:

The code is as follows:

// PHP decompress the file (zip)
Function unzip_file ($ file, $ destination ){
$ Zip = new ZipArchive ();
// Open the compressed file
If ($ zip-> open ($ file )! = TRUE ){
Die ('could not open Archive ');
}
// Create a file
$ Zip-> extrac.pdf ($ destination );
$ Zip-> close ();
Echo 'successfully ';
}
Unzip_file ("htdocs.zip", "wenjianming ");

Detected during execution
The code is 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


The root permission may be required when you use the make install command. Therefore, we recommend that you use sudo to run the command. After installation, the location of zip. so is displayed. Record it, for example,/usr/local/lib/php/extensions/zip. so.

2. use root permission to modify php. ini (usually in the/usr/local/lib/folder, but depending on the initial installation of php, you can view it through phpinfo ):
Add extension =/usr/local/lib/php/extensions/zip. so, and change zlib. output_compression = Off to zlib. output_compression = On in the php. ini file;

3. do not forget to restart Apache: apachectl restart;

Note: some friends on the website say zlib. change output_compression = Off to zlib. output_compression = On; I have not operated On php in windows. ini file is not seen, but it can indeed generate or decompress the file.

I hope this article will help you with PHP programming.

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.