Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

PHP ZipArchive getArchiveComment() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The ZipArchive::getArchiveComment() function is an inbuilt function in PHP that is used to return the zip archive comment.

Syntax:

string|false ZipArchive::getArchiveComment(int $flags = 0)

Parameters: This function accepts a single parameter that is described below.

  • $flag: This parameter holds the flag and if the flag is set to  ZipArchive::FL_UNCHANGED, then an unchanged archive comment is returned.

Return Value: This function returns the zip archive comment or “false” on failure.

Example 1: The following code demonstrates the getArchiveComment() function.

PHP




<?php
 
    // Create a new ZipArchive object
    $zip = new ZipArchive;
 
    // Check for opening the zip file
    if ($zip->open('Geeks.zip', ZipArchive::CREATE))
    {
         
        // Get the archive comment
        var_dump($zip->getArchiveComment());
         
        // Close the zip file
        $zip->close();
    }
    // If zip file is not open/exist
    else {
        echo 'Failed to open zip file';
    }
?>


Output:

string(0) ""

Example 2: The following code demonstrates the setArchiveComment() function which set the given string as shown in the output.

PHP




<?php
 
    // Create a new ZipArchive object
    $zip = new ZipArchive;
 
    // Check for opening the zip file
    if ($zip->open('Geeks.zip', ZipArchive::CREATE)) {
         
        $zip->setArchiveComment('GeeksforGeeks Archive Comment');
         
        var_dump($zip->getArchiveComment());
         
        // Close the zip file
        $zip->close();
    }
    // If zip file is not open/exist
    else
    {
        echo 'Failed to open zip file';
    }
?>


Output:

string(29) "GeeksforGeeks Archive Comment"

Reference: https://www.php.net/manual/en/ziparchive.getarchivecomment.php


My Personal Notes arrow_drop_up
Last Updated : 23 Mar, 2023
Like Article
Save Article
Similar Reads
Related Tutorials