(PHP >= 8.3.0, PECL zip >= 1.22.0)
ZipArchive::setArchiveFlag — Set a global flag of a ZIP archive
public ZipArchive::setArchiveFlag(int $flag, int $value): bool
Set a global flag of a ZIP archive.
flag The global flag to change, among AFL_* constants.
valueThe new value of the flag.
Example #1 Create a torrentzip archive
<?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';
}
?>
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/ziparchive.setarchiveflag.php