Home > Backend Development > PHP Tutorial > 哥哥姐姐们 PHP如何压缩大文件

哥哥姐姐们 PHP如何压缩大文件

WBOY
Release: 2016-06-13 10:27:42
Original
1732 people have browsed it

哥哥姐姐们 PHP怎么压缩大文件
  要压缩的文件最少为40M

我的代码
$data       =       implode(   "   ",       file(   "timer.php "));
$gzdata       =       gzencode($data,       9);
$fp       =       fopen(   "file.php.gz   ",       "w   ");
fwrite($fp,       $gzdata);
fclose($fp)



------解决方案--------------------
http://php.net/manual/zh/refs.compression.php
------解决方案--------------------
zlib支持字节流,不过php接口太简化了,你可以用:
http://www.php.net/manual/zh/function.gzopen.php

打开普通文件,fopen+fread慢慢读,然后gzopen+gzwrite慢慢写。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template