ZipArchive::setArchiveFlag
PHP function
Edit on GitHub ✎
(PHP >= 8.3.0, PECL zip >= 1.22.0)
Set a global flag of a ZIP archive
Description
ZipArchive::setArchiveFlag(int $flag, int $value): bool
Set a global flag of a ZIP archive.
Parameters
flagThe global flag to change, among
AFL_*constants.ZipArchive::AFL_WANT_TORRENTZIPZipArchive::AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE
valueThe new value of the flag.
Return Values
Success
Examples
Create a torrentzip archive
php
<?php
$zip = new ZipArchive;
$res = $zip->open('test.zip', ZipArchive::CREATE);
if ($res === TRUE) {
$zip->setArchiveFlag(ZipArchive::AFL_WANT_TORRENTZIP, 1);
$zip->addFromString('test.txt', 'file content goes here');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>See Also
ZipArchive::getArchiveFlag