ZipArchive::getArchiveComment() 函數是 PHP 中的內置函數,用於返回 zip 存檔注釋。
用法:
string|false ZipArchive::getArchiveComment(int $flags = 0)
參數:該函數接受如下所述的單個參數。
- $flag:此參數保存標誌,如果該標誌設置為 ZipArchive::FL_UNCHANGED,則返回未更改的存檔注釋。
返回值:此函數在失敗時返回 zip 存檔注釋或“false”。
示例 1:下麵的代碼演示了getArchiveComment()函數。
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';
}
?>
輸出:
string(0) ""
示例 2:下麵的代碼演示了setArchiveComment()函數設置給定的字符串,如輸出所示。
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';
}
?>
輸出:
string(29) "GeeksforGeeks Archive Comment"
參考: https://www.php.net/manual/en/ziparchive.getarchivecomment.php
相關用法
- PHP ZipArchive deleteIndex()用法及代碼示例
- PHP ZipArchive close()用法及代碼示例
- PHP ZipArchive count()用法及代碼示例
- PHP ZipArchive deleteName()用法及代碼示例
- PHP ZipArchive extractTo()用法及代碼示例
- PHP ZipArchive addFromString()用法及代碼示例
- PHP ZipArchive::addEmptyDir()用法及代碼示例
- PHP Hebrev()用法及代碼示例
- PHP Max()用法及代碼示例
- PHP String htmlspecialchars()用法及代碼示例
- PHP String htmlspecialchars_decode()用法及代碼示例
- PHP String localeconv()用法及代碼示例
- PHP String nl2br()用法及代碼示例
- PHP String nl_langinfo()用法及代碼示例
- PHP String quoted_printable_decode()用法及代碼示例
- PHP String quoted_printable_encode()用法及代碼示例
- PHP String sprintf()用法及代碼示例
- PHP String sscanf()用法及代碼示例
- PHP String str_replace()用法及代碼示例
- PHP String strrpos()用法及代碼示例
- PHP String strspn()用法及代碼示例
- PHP String strstr()用法及代碼示例
- PHP String strtok()用法及代碼示例
- PHP String strtolower()用法及代碼示例
- PHP String strtoupper()用法及代碼示例
注:本文由純淨天空篩選整理自vkash8574大神的英文原創作品 PHP ZipArchive getArchiveComment() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。