ZipArchive::setCompressionName
(PHP 7, PECL zip >= 1.13.0)
ZipArchive::setCompressionName - 设置由其名称定义的条目的压缩方法
描述
bool ZipArchive::setCompressionName ( string $name , int $comp_method [, int $comp_flags = 0 ] )
设置由其名称定义的条目的压缩方法。
参数
name
条目的名称。
comp_method
压缩方法。要么ZipArchive::CM_DEFAULT
,ZipArchive::CM_STORE
要么ZipArchive::CM_DEFLATE
。
comp_flags
压缩标志。目前尚未使用。
返回值
成功时返回TRUE
或失败时返回FALSE
。
示例
Example #1 Add files with different compression methods to an archive
<?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 →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com