Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

deflate_add

Description

The deflate_add of zlib for PHP incrementally deflates data.

Syntax

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

Parameters

context

A context created with deflate_init().

data

A chunk of data to compress.

flush_mode

One of ZLIB_BLOCK, ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH (default), ZLIB_FULL_FLUSH, ZLIB_FINISH.

Normally, set ZLIB_NO_FLUSH to maximize compression and ZLIB_FINISH to terminate with the last chunk of data.

Return

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

Examples

1 · context data

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$context = deflate_init($encoding);
$data = "data";

$return = deflate_add($context, $data);

echo $return;

?>
x�JI,I��

2 · flush_mode · ZLIB_BLOCK

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$context = deflate_init($encoding);
$data = "data";
$flush_mode = ZLIB_BLOCK;

$return = deflate_add($context, $data, $flush_mode);

echo $return;

?>
x�JI,I

3 · flush_mode · ZLIB_NO_FLUSH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$context = deflate_init($encoding);
$data = "data";
$flush_mode = ZLIB_NO_FLUSH;

$return = deflate_add($context, $data, $flush_mode);

echo $return;

?>
x�

4 · flush_mode · ZLIB_PARTIAL_FLUSH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$context = deflate_init($encoding);
$data = "data";
$flush_mode = ZLIB_PARTIAL_FLUSH;

$return = deflate_add($context, $data, $flush_mode);

echo $return;

?>
x�JI,I

5 · flush_mode · ZLIB_SYNC_FLUSH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$context = deflate_init($encoding);
$data = "data";
$flush_mode = ZLIB_SYNC_FLUSH;

$return = deflate_add($context, $data, $flush_mode);

echo $return;

?>
x�JI,I��

6 · flush_mode · ZLIB_FULL_FLUSH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$context = deflate_init($encoding);
$data = "data";
$flush_mode = ZLIB_FULL_FLUSH;

$return = deflate_add($context, $data, $flush_mode);

echo $return;

?>
x�JI,I��

7 · flush_mode · ZLIB_FINISH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$context = deflate_init($encoding);
$data = "data";
$flush_mode = ZLIB_FINISH;

$return = deflate_add($context, $data, $flush_mode);

echo $return;

?>
x�KI,I�
HomeMenu