php使用ZipArchive提示Fatal error: Class ZipArchive not found in的解决方法,ziparchivefatal
php使用ZipArchive提示Fatal error: Class ZipArchive not found in的解决方法,ziparchivefatal
本文实例讲述了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");
执行时发现
Fatal error: Class 'ZipArchive' not found in E:wwwqqdown.php on line 63
看这个不是未定义了,所以小编百度搜索一下,如下如下解说
在Windows下的解决办法是:
1、在php.ini文件中,将extension=php_zip.dll前面的分号“;”去除;
重启Apache服务器,我们再试发现可以了
补充:
如果是linux系统参考下面方法
在Linux下没有php_zip.dll这个文件
需要重新编译一下php的zip模块。具体安装方法如下:
复制代码 代码如下:
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程序设计有所帮助。
在php.ini里面把;extension=php_zip.dll前面的分号去掉。前提是你安装的php里面ext文件夹里面有php_zip.dll
The php_zip.dll not exist,you should find php_zip.dll file in you computer for my mind ..

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



In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

PS "Loading" problems are caused by resource access or processing problems: hard disk reading speed is slow or bad: Use CrystalDiskInfo to check the hard disk health and replace the problematic hard disk. Insufficient memory: Upgrade memory to meet PS's needs for high-resolution images and complex layer processing. Graphics card drivers are outdated or corrupted: Update the drivers to optimize communication between the PS and the graphics card. File paths are too long or file names have special characters: use short paths and avoid special characters. PS's own problem: Reinstall or repair the PS installer.

The... (splat) operator in PHP is used to unpack function parameters and arrays, improving code simplicity and efficiency. 1) Function parameter unpacking: Pass the array element as a parameter to the function. 2) Array unpacking: Unpack an array into another array or as a function parameter.

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

In PHP, the final keyword is used to prevent classes from being inherited and methods being overwritten. 1) When marking the class as final, the class cannot be inherited. 2) When marking the method as final, the method cannot be rewritten by the subclass. Using final keywords ensures the stability and security of your code.

A PS stuck on "Loading" when booting can be caused by various reasons: Disable corrupt or conflicting plugins. Delete or rename a corrupted configuration file. Close unnecessary programs or upgrade memory to avoid insufficient memory. Upgrade to a solid-state drive to speed up hard drive reading. Reinstalling PS to repair corrupt system files or installation package issues. View error information during the startup process of error log analysis.

Frequently Asked Questions and Solutions when Exporting PS as PDF: Font Embedding Problems: Check the "Font" option, select "Embed" or convert the font into a curve (path). Color deviation problem: convert the file into CMYK mode and adjust the color; directly exporting it with RGB requires psychological preparation for preview and color deviation. Resolution and file size issues: Choose resolution according to actual conditions, or use the compression option to optimize file size. Special effects issue: Merge (flatten) layers before exporting, or weigh the pros and cons.

Strict types in PHP are enabled by adding declare(strict_types=1); at the top of the file. 1) It forces type checking of function parameters and return values to prevent implicit type conversion. 2) Using strict types can improve the reliability and predictability of the code, reduce bugs, and improve maintainability and readability.
