zip_entry_name()函數是PHP中的內置函數,用於返回zip歸檔條目的名稱。將讀取zip條目資源並將其作為參數發送到zip_entry_name()函數,並且它將在成功時返回zip條目存檔的名稱。
用法:
string zip_entry_name( $zip_entry )
參數:該函數接受強製性的單個參數$zip_entry。用於指定郵政編碼條目資源。
返回值:它返回成功時的zip歸檔條目的名稱。
錯誤和異常:
- zip_entry_name()僅在成功時返回zip條目歸檔文件的名稱,否則將返回PHP警告。
- 如果zip存檔無效,則zip_entry_name()函數將返回ER_OPEN錯誤。
- 如果zip存檔為空,則zip_entry_name()函數返回ER_NOZIP錯誤。
以下示例程序旨在說明PHP中的zip_entry_name()函數:
程序1:
Suppose a zip file article.zip contains the following file:
content.xlsx
<?php
// Opening a zip file
$zip_handle = zip_open("C:/xampp/htdocs/article.zip");
// Reading a zip entry archive
$zip_entry = zip_read($zip_handle);
// Reading the name of a zip entry archive
$file = zip_entry_name($zip_entry);
echo("File Name:" . $file);
// Closing the zip archive
zip_close($zip_handle);
?>
輸出:
File Name:article/content.xlsx
程序2:
Suppose a zip file article.zip contains following files and directories:
Directory:img
- geeksforgeeks.png
- geeksforgeeks1.png
content.xlsx
gfg.pdf
image.jpeg
<?php
// Opening a zip file
$zip_handle = zip_open("C:/xampp/htdocs/article.zip");
if(is_resource($zip_handle))
{
while($zip_entry = zip_read($zip_handle))
{
$file = zip_entry_name($zip_entry);
// Checking the file name of a zip archive entry
$file_name = zip_entry_name($zip_entry);
echo("File Name:" . $file_name . "<br>");
}
// closing the zip archive
zip_close($zip_handle);
}
else
echo("Zip archive cannot be read.");
?>
輸出:
File Name:article/content.xlsx File Name:article/gfg.pdf File Name:article/image.jpeg File Name:article/img/ File Name:article/img/geeksforgeeks.png File Name:article/img/geeksforgeeks1.png
相關文章:
- PHP - zip_read()用法及代碼示例
- PHP - zip_close( )用法及代碼示例
- PHP - zip_entry_close()用法及代碼示例
- PHP - zip_entry_compressedsize()用法及代碼示例
參考: http://php.net/manual/en/function.zip-entry-name.php
相關用法
- d3.js d3.lab()用法及代碼示例
- PHP exp()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
- d3.js d3.hcl()用法及代碼示例
- PHP sin( )用法及代碼示例
- PHP abs()用法及代碼示例
- PHP cos( )用法及代碼示例
- PHP tan( )用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP next()用法及代碼示例
- PHP Ds\Map get()用法及代碼示例
- d3.js d3.sum()用法及代碼示例
注:本文由純淨天空篩選整理自Shubrodeep Banerjee大神的英文原創作品 PHP | zip_entry_name() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。