[英]PHP 7.2.7: Attempted to call an undefined method named “setEncryptionName” of class “ZipArchive”
I am attempting to create an encrypted, password protected ZIP file using PHP 7.2.7. 我试图使用PHP 7.2.7创建一个加密的,受密码保护的ZIP文件。 However, I am getting the following error message:
但是,我收到以下错误消息:
Attempted to call an undefined method named "setEncryptionName" of class "ZipArchive".
http://php.net/manual/en/ziparchive.setencryptionname.php http://php.net/manual/en/ziparchive.setencryptionname.php
If I remove $zip->setEncryptionName()
then everything works 100%, except that the ZIP file is then not password protected. 如果我删除
$zip->setEncryptionName()
那么一切都可以100%工作,但ZIP文件不受密码保护。
I have done a Google & Forum search and cannot find anybody that has experienced a similar problem, probably because the PHP version and functionality is still so new. 我已经完成了谷歌和论坛搜索,找不到任何遇到类似问题的人,可能是因为PHP版本和功能仍然很新。
For the ZipArchive::setEncryptionName
method to work You will need PHP >= 7.2 With the ZIP extension. 使
ZipArchive::setEncryptionName
方法工作您将需要PHP> = 7.2使用ZIP扩展名。
Note the the ZIP extension needs to be compiled with libzip-dev
>= 1.2.0 请注意,ZIP扩展需要使用
libzip-dev
> = 1.2.0进行编译
A common issue in many pre-compiled packages is that the compiler did not upgrade libzip-dev before compiling the php-zip
extension. 许多预编译包中的一个常见问题是编译器在编译
php-zip
扩展之前没有升级libzip-dev。 Which is probably your case. 这可能是你的情况。
Be aware that your ZIPs will not be encrypted and that the setPassword()
function is only used to extract zips if ZipArchive::setEncryptionName
is not available. 请注意,如果
ZipArchive::setEncryptionName
不可用,您的ZIP将不会被加密,并且setPassword()
函数仅用于提取拉链。
Here is the changelog: http://pecl.php.net/package-info.php?package=zip&version=1.14.0 这是更改日志: http : //pecl.php.net/package-info.php? package = zip&version = 1.14.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.