php8.5
Home/ Manual/ zip / ziparchive/ ZipArchive::setArchiveComment

ZipArchive::setArchiveComment

PHP function Edit on GitHub ✎

(PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.4.0)

Set the comment of a ZIP archive

Description

ZipArchive::setArchiveComment(string $comment): bool

Set the comment of a ZIP archive.

Parameters

comment

The contents of the comment.

Return Values

Success

Examples

Create an archive and set a comment

php
<?php
$zip = new ZipArchive;
$res = $zip->open('test.zip', ZipArchive::CREATE);
if ($res === TRUE) {
    $zip->addFromString('test.txt', 'file content goes here');
    $zip->setArchiveComment('new archive comment');
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
?>

Source: reference/zip/ziparchive/setarchivecomment.xml · from the official PHP manual (php/doc-en)