ZLIB_ENCODING_RAW
ZLIB_ENCODING_RAW = -15
cfw_zlib(string $op, string $data, int $level = -1, string $dict = '') : array{ok: bool, data?: string, error?: string}
Runs one op over the bridge.
| string | $op | gzip, gunzip, zlib, unzlib, deflate or inflate. |
| string | $data | The bytes to transform. |
| int | $level | A zlib level, or -1 for the default. |
| string | $dict | A preset dictionary, or an empty string for none. |
['ok' => true, 'data' => string] or ['ok' => false, 'error' => string].
cfw_zlib_dict(string $op, string $data, string $dict, int $level = -1) : string|false
Compresses or decompresses against a preset dictionary.
NOT shaped like a gz* function: PHP has never had a dictionary parameter on gzcompress(), so widening one of those signatures would make a host-only argument look like part of the language. function_exists('cfw_zlib_dict') is the feature test a caller uses.
$op is 'zlib' to compress and 'unzlib' to decompress; the output is an ordinary zlib stream with FDICT set. gzip and the raw pair are refused, because neither has anywhere to record the dictionary's checksum -- so a wrong dictionary would decode to plausible garbage instead of failing.
| string | $op | zlib or unzlib. |
| string | $data | The bytes to transform. |
| string | $dict | The preset dictionary. |
| int | $level | A zlib level, or -1 for the default. |
The bytes, or FALSE with an E_USER_WARNING, matching the gz* functions.
cfw_zlib_encoding(string $name, int $encoding) : string
The container an encoding names.
All three encoders accept all three encodings and emit that container -- measured on 8.5.7, gzcompress(x, 9, ZLIB_ENCODING_GZIP) is byte-identical to gzencode(x, 9, FORCE_GZIP) -- so the three share one mapping.
| string | $name | The PHP function being called. |
| int | $encoding | A ZLIB_ENCODING_* value. |
cfw_zlib_cap(string $name, string $data, int $max_length) : string|false
Applies $max_length the way zlib does, which is NOT a truncation.
Measured: gzuncompress(gzcompress('hello world'), 5) is FALSE, not 'hello'. zlib fails the inflate when its output buffer is too small, so a cap below the payload is a data error rather than a short read. 0 means no cap.
| string | $name | The PHP function being called. |
| string | $data | The inflated bytes. |
| int | $max_length | The cap, or 0 for none. |
The bytes, or FALSE with an E_USER_WARNING when the cap was exceeded.