PHP | zip_entry_close()函数
zip_entry_close()函数是PHP中的一个内置函数,用于关闭由 zip_entry_open()函数打开的 zip 存档。 zip_entry_close() 导致流被关闭,并且与可能是 Zip 存档中的文件或目录的相应 Zip 存档条目的连接被破坏。必须关闭的 zip 条目资源作为参数发送到 zip_entry_close()函数。
句法:
bool zip_entry_close ( $zip_entry )
参数: zip_entry_close()函数接受单个参数$zip_entry 。它是一个强制参数,用于指定 zip 条目资源。
返回值:成功时返回 true,失败时返回 False。
错误和异常:
- 必须首先使用PHP zip_entry_open()函数打开要关闭的 zip 条目存档,否则PHP zip_entry_close()函数会产生PHP警告。
- 如果 zip 存档无效,则 zip_entry_close()函数会返回 ER_OPEN 错误。
- 如果 zip 存档为空,则 zip_entry_close()函数会返回 ER_NOZIP 错误。
Suppose a zip file article.zip contains the following file:
content.xlsx
下面的程序说明了PHP中的 zip_entry_close()函数:
方案一:
输出:
Zip Entry Archive: article/content.xlsx has been closed successfully.
Suppose a zip file article.zip contains the following files:
content.xlsx
gfg.pdf
image.jpeg
方案二:
");
// Closing a zip archive entry
$flag = zip_entry_close($zip_entry);
if ($flag == true)
echo("Zip Entry Archive: " . $file_name .
" has been closed successfully." . "
");
else
echo("Zip Entry Archive: " . $file_name .
" cannot be closed." . "
");
}
else
echo("Zip Entry Cannot be opened.");
}
// Closing a zip archive
zip_close($zip_handle);
}
else
echo("Failed to Open" . $zip_handle );
?>
输出:
Zip Entry Archive: article/content.xlsx has been opened successfully.
Zip Entry Archive: article/content.xlsx has been closed successfully.
Zip Entry Archive: article/gfg.pdf has been opened successfully.
Zip Entry Archive: article/gfg.pdf has been closed successfully.
Zip Entry Archive: article/image.jpeg has been opened successfully.
Zip Entry Archive: article/image.jpeg has been closed successfully.
参考: 函数 : PHP 。 PHP