gzencode() - zlib函数(压缩文件)
gzencode()
(PHP 4 >= 4.0.4, PHP 5, PHP 7)
创建gzip压缩字符串
说明
gzencode (string $data[,int $level= -1 [,int $encoding_mode= FORCE_GZIP ]] ) : stringThis function returns a compressed version of the input$datacompatible with the output of the gzip program.
For more information on the GZIP file format, see the document: » GZIP file format specification version 4.3 (RFC 1952).
参数
$dataThe data to encode.
$level压缩程度。如果不压缩到9,则可以指定为0。用于最大压缩。如果未给定,则默认压缩级别将。是zlib库的默认压缩级别。
$encoding_mode The encoding mode. Can be FORCE_GZIP
(the default) or FORCE_DEFLATE
.
Prior to PHP 5.4.0, using FORCE_DEFLATE
results in a standard zlib deflated string (inclusive zlib headers) after a gzip file header but without the trailing crc32 checksum.
In PHP 5.4.0 and later, FORCE_DEFLATE
generates RFC 1950 compliant output, consisting of a zlib header, the deflated data, and an Adler checksum.
返回值
The encoded string, or FALSE
if an error occurred.
更新日志
版本 | 说明 |
---|---|
5.4.0 | FORCE_DEFLATE now generates RFC 1950 compliant output. |
范例
The resulting data contains the appropriate headers and data structure to make a standard .gz file, e.g.:
Creating a gzip file
参见
gzdecode()
Decodes a gzip compressed stringgzdeflate()
Deflate a stringgzinflate()
Inflate a deflated stringgzuncompress()
Uncompress a compressed stringgzcompress()
Compress a string- » ZLIB Compressed Data Format Specification (RFC 1950)
Had some trouble finding the correct way to send a Content-Length header with HTTP compression. The pitch is to use gzencode (not gzdeflaten not gzcompress).
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!