Latest web development tutorials

PHP zip_entry_read () function

PHP Zip File Reference Complete PHP Zip File Reference

Definition and Usage

zip_entry_read () function to get the contents from the open zip file.

If successful, the function returns the contents of the project. If it fails, it returns FALSE.

grammar

zip_entry_read(zip_entry,length)

参数 描述
zip_entry 必需。规定要读取的 zip 项目资源(由 zip_read() 打开的 zip 项目)。
length 可选。规定返回的字节数(未压缩尺寸)。默认是 1024。


Examples

<?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);
}
?>

Output code depends on the contents of the zip file:

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 thezip functionsin PHP.


PHP Zip File Reference Complete PHP Zip File Reference