PHP zip_entry_read() 函數(shù)

2018-12-07 19:09 更新

PHP zip_entry_read() 函數(shù)


PHP Zip File 參考手冊 完整的 PHP Zip File 參考手冊

定義和用法

zip_entry_read() 函數(shù)從打開的 zip 檔案中獲取內(nèi)容。

如果成功,該函數(shù)則返回項(xiàng)目的內(nèi)容。如果失敗,則返回 FALSE。

語法

zip_entry_read(zip_entry,length)

參數(shù) 描述
zip_entry 必需。規(guī)定要讀取的 zip 項(xiàng)目資源(由 zip_read() 打開的 zip 項(xiàng)目)。
length 可選。規(guī)定返回的字節(jié)數(shù)(未壓縮尺寸)。默認(rèn)是 1024。


實(shí)例

<?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 檔案的內(nèi)容:

Name: ziptest.txt
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 Zip File 參考手冊 完整的 PHP Zip File 參考手冊
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號