如何使用 PHP 读取 zip 压缩包中的单个文件

phpserver side programmingprogramming更新于 2025/6/28 0:07:17

要读取 zip 压缩包中的单个文件,代码如下 −

$handle = fopen('zip://test.zip#test.txt', 'r');
$result = '';
while (!feof($handle)) {
   $result .= fread($handle, 8192);
}
fclose($handle);
echo $result;

输出将是 zip 文件的内容。


相关文章