deflate_init()

deflate_init() — Initialize an incremental deflate context.

Built-in function of PHP 8.5. The manual lists it as available in PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Initializes an incremental deflate context using the specified encoding.

Signature

deflate_init(int $encoding, array|object $options = []): DeflateContext|false

Parameters

ParameterTypeWhat it takes
$encodingintOne of the ZLIB_ENCODING_* constants.
$optionsarray|objectAn associative array which may contain the following elements: level The compression level in range -1..9; defaults to -1. memory The compression memory level in range 1..9; defaults to 8. window The zlib window size (logarithmic) in range 8..15; defaults to 15. zlib changes a window size of 8 to 9, and as of zlib 1.2.8 fails with a warning, if a window size of 8 is requested for ZLIB_ENCODING_RAW or ...

Return value

Returns a deflate context resource (zlib.deflate) on success, or false on failure.

Example

The PHP manual ships no example for deflate_init(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.0.0On success, this function returns a DeflateContext instance now; previously, a resource was returned.

See also

deflate_add(), inflate_init()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page deflate_init() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.