deflate_add()

deflate_add() — Incrementally deflate data.

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

Incrementally deflates data in the specified context.

Signature

deflate_add(DeflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false

Parameters

ParameterTypeWhat it takes
$contextDeflateContextA context created with deflate_init().
$datastringA chunk of data to compress.
$flush_modeintOne of ZLIB_BLOCK, ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH (default), ZLIB_FULL_FLUSH, ZLIB_FINISH. Normally you will want to set ZLIB_NO_FLUSH to maximize compression, and ZLIB_FINISH to terminate with the last chunk of data. See the zlib manual for a detailed description of these constants.

Return value

Returns a chunk of compressed data, or false on failure.

Example

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

Changelog

VersionChange
8.0.0context expects a DeflateContext instance now; previously, a resource was expected.

See also

deflate_init()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page deflate_add() (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.