ZipArchive::setArchiveFlag

Set a global flag of a ZIP archive

Description

public bool ZipArchive::setArchiveFlag(int $flag, int $value)

Set a global flag of a ZIP archive.

Parameters

flag

The global flag to change, among AFL_* constants.

  • ZipArchive::AFL_WANT_TORRENTZIP

  • ZipArchive::AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE

value

The new value of the flag.

Return Values

Returns true on success or false on failure.

Examples

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';
}
?>

See Also

  • ZipArchive::getArchiveFlag