首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ZipArchive::setCompressionName

(PHP 7, PECL zip >= 1.13.0)

ZipArchive::setCompressionName - 设置由其名称定义的条目的压缩方法

描述

代码语言:javascript
复制
bool ZipArchive::setCompressionName ( string $name , int $comp_method [, int $comp_flags = 0 ] )

设置由其名称定义的条目的压缩方法。

参数

name

条目的名称。

comp_method

压缩方法。要么ZipArchive::CM_DEFAULTZipArchive::CM_STORE要么ZipArchive::CM_DEFLATE

comp_flags

压缩标志。目前尚未使用。

返回值

成功时返回TRUE或失败时返回FALSE

示例

Example #1 Add files with different compression methods to an archive

代码语言:javascript
复制
<?php
$zip?=?new?ZipArchive;
$res?=?$zip->open('test.zip',?ZipArchive::CREATE);
if?($res?===?TRUE)?{
????$zip->addFromString('foo',?'Some?text');
????$zip->addFromString('bar',?'Some?other?text');
????$zip->setCompressionName('foo',?ZipArchive::CM_STORE);
????$zip->setCompressionName('bar',?ZipArchive::CM_DEFLATE);
????$zip->close();
????echo?'ok';
}?else?{
????echo?'failed';
}
?>

← ZipArchive::setCompressionIndex

ZipArchive::setEncryptionIndex →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com