PHP zip_entry_read() 函數
PHP zip_entry_read() 函數

定義和用法
zip_entry_read() 函數從打開的 zip 檔案中獲取內容。
如果成功,該函數則返回項目的內容。如果失敗,則返回 FALSE。
語法
zip_entry_read(zip_entry,length)
參數 | 描述 |
---|---|
zip_entry | 必需。規定要讀取的 zip 項目資源(由 zip_read() 打開的 zip 項目)。 |
length | 可選。規定返回的字節數(未壓縮尺寸)。默認是 1024。 |
實例
<?php
$zip = zip_open("test.zip");
if ($zip)
{
while ($zip_entry = zip_read($zip))
{
echo "<p>";
echo "Name: " . zip_entry_name($zip_entry) . "<br />";
if (zip_entry_open($zip, $zip_entry))
{
echo "File Contents:<br/>";
$contents = zip_entry_read($zip_entry);
echo "$contents<br />";
zip_entry_close($zip_entry);
}
echo "</p>";
}
zip_close($zip);
}
?>
$zip = zip_open("test.zip");
if ($zip)
{
while ($zip_entry = zip_read($zip))
{
echo "<p>";
echo "Name: " . zip_entry_name($zip_entry) . "<br />";
if (zip_entry_open($zip, $zip_entry))
{
echo "File Contents:<br/>";
$contents = zip_entry_read($zip_entry);
echo "$contents<br />";
zip_entry_close($zip_entry);
}
echo "</p>";
}
zip_close($zip);
}
?>
代碼的輸出取決于 zip 檔案的內容:
Name: ziptest.txt
File Contents:
Hello World! This is a test for a the zip functions in PHP.
Name: htmlziptest.html
File Contents:
File Contents:
Hello World! This is a test for a the zip functions in PHP.
Name: htmlziptest.html
File Contents:
Hello World!
This is a test for a the zip functions in PHP.
相關文章
- PHP 字符串
- PHP Switch 語句
- PHP 數組排序
- PHP 函數
- PHP 命名空間 namespace
- PHP 發送電子郵件
- PHP Secure E-mails
- PHP array_change_key_case() 函數
- PHP array_pad() 函數
- PHP array_reduce() 函數
- PHP array_reverse() 函數
- PHP array_search() 函數
- PHP array_uintersect() 函數
- PHP count() 函數
- PHP shuffle() 函數
- PHP sort() 函數
- PHP usort() 函數
- PHP 5 Filesystem 函數
- PHP Libxml 函數
- PHP 雜項 函數