ZipArchive::getArchiveFlag
(PHP >= 8.3.0, PECL zip >= 1.22.0)
Returns the value of a Zip archive global flag
Description
Returns a Zip archive global flag value.
Parameters
flagThe global flag to retrieve, among
AFL_*constants:ZipArchive::AFL_RDONLYZipArchive::AFL_IS_TORRENTZIPZipArchive::AFL_WANT_TORRENTZIPZipArchive::AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE
flagsIf
flagsis set toZipArchive::FL_UNCHANGED, the original unchanged flag is returned.
Return Values
Returns 1 if flag is set for archive, 0 if not, and -1 if an error occurred.
Both 1 and -1 are truthy, so a plain truth test treats an error as the flag being set. The result must be compared strictly against 1.
Examples
Test if archive is a torrentzip format
<?php
$zip = new ZipArchive();
$res = $zip->open('test.zip');
if ($res === true) {
var_dump($zip->getArchiveFlag(ZipArchive::AFL_IS_TORRENTZIP));
} else {
echo 'Failed, code: ' . $res;
}
?>See Also
ZipArchive::setArchiveFlag