


php使用ZipArchive提示Fatal error: Class ZipArchive not found in的_PHP
本文实例讲述了php使用ZipArchive提示Fatal error: Class ZipArchive not found in的解决方法。分享给大家供大家参考。具体如下:
ZipArchive是php自带的一个压缩与解压缩函数了,今天理所当然的情况中使用new ZipArchive来创建zip文件时碰到提示Fatal error: Class ZipArchive not found in错误,感兴趣的朋友就一起来看看解决方法。
测试代码如下:
代码如下:
//PHP解压缩文件(zip)
function unzip_file($file, $destination){
$zip = new ZipArchive() ;
//打开压缩文件
if ($zip->open($file) !== TRUE) {
die ('Could not open archive');
}
//创建文件
$zip->extractTo($destination);
$zip->close();
echo '成功';
}
unzip_file("htdocs.zip","wenjianming");
执行时发现
代码如下:
cd /usr/src
wget http://pecl.php.net/get/zip
tar -zxvf zip
cd zip-1.x.x
phpize
./configure
make
sudo make install
其中, 在最后使用make install命令的时候,可能需要用到root的权限,所以建议使用sudo来运行。安装完之后,屏幕上会提示zip.so的位置。然后将其记录下来,如:/usr/local/lib/php/extensions/zip.so。
2、使用root权限修改php.ini(通常可能会在/usr/local/lib/文件夹下,不过视当初安装php而定,可以通过phpinfo()来查看):
增加extension = /usr/local/lib/php/extensions/zip.so,然后同样在php.ini文件中,将 zlib.output_compression = Off 改为 zlib.output_compression = On ;
3、最后别忘了重启一下Apache:apachectl restart;
注意:关于网站有一些朋友说zlib.output_compression = Off 改为 zlib.output_compression = On ; 我在windows下没有操作在php.ini文件中也没有看到但这样确实是可以生成或解压文件。
希望本文所述对大家的PHP程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide
