zlib_encode
Description
The zlib_encode of zlib for PHP compresses data with the specified encoding.
Syntax
zlib_encode( string $data, int $encoding, int $level = -1 ): string|false
Parameters
data
The data to compress.
encoding
The encoding mode.
Constant | Description |
---|---|
ZLIB_ENCODING_RAW | DEFLATE algorithm as per RFC 1951. |
ZLIB_ENCODING_DEFLATE | ZLIB compression algorithm as per RFC 1950. |
ZLIB_ENCODING_GZIP | GZIP algorithm as per RFC 1952. |
level
The level of compression.
Can be given as 0 for no compression up to 9 for maximum compression. If -1 is used, the default compression of the zlib library is used which is 6.
Return
Returns the compressed string or false if an error occurred.
Examples
1 · data encoding · ZLIB_ENCODING_RAW
<? $data = "data"; $encoding = ZLIB_ENCODING_RAW; $return = zlib_encode($data, $encoding); echo $return; ?>
KI,I