PHP ZipArchive getArchiveComment() Function
Last Updated :
23 Mar, 2023
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
$zip = new ZipArchive;
if ( $zip ->open( 'Geeks.zip' , ZipArchive::CREATE))
{
var_dump( $zip ->getArchiveComment());
$zip ->close();
}
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
$zip = new ZipArchive;
if ( $zip ->open( 'Geeks.zip' , ZipArchive::CREATE)) {
$zip ->setArchiveComment( 'GeeksforGeeks Archive Comment' );
var_dump( $zip ->getArchiveComment());
$zip ->close();
}
else
{
echo 'Failed to open zip file' ;
}
?>
|
Output:
string(29) "GeeksforGeeks Archive Comment"
Reference: https://www.php.net/manual/en/ziparchive.getarchivecomment.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...