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

inflate_add

Description

The inflate_add of zlib for PHP incrementally inflate encoded data.

Syntax

inflate_add(
    InflateContext $context,
    string $data,
    int $flush_mode = ZLIB_SYNC_FLUSH
): string|false

Parameters

context

A context created with inflate_init().

data

A chunk of compressed data.

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 uncompressed data, or false on failure.

Examples

1 · context data

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$deflate_initcontext = deflate_init($encoding);
$deflate_initdata = "data";

$deflate_initreturn = deflate_add($deflate_initcontext, $deflate_initdata);

echo $deflate_initreturn . PHP_EOL;

$context = inflate_init($encoding);
$data = $deflate_initreturn;

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

var_dump($return);
x�JI,I��
string(4) "data"

2 · flush_mode · ZLIB_BLOCK

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$deflate_initcontext = deflate_init($encoding);
$deflate_initdata = "data";
$deflate_initflush_mode = ZLIB_BLOCK;

$deflate_initreturn = deflate_add($deflate_initcontext, $deflate_initdata, $deflate_initflush_mode);

echo $deflate_initreturn . PHP_EOL;

$context = inflate_init($encoding);
$data = $deflate_initreturn;
$flush_mode = $deflate_initflush_mode;

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

var_dump($return);
x�JI,I
string(0) ""

3 · flush_mode · ZLIB_NO_FLUSH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$deflate_initcontext = deflate_init($encoding);
$deflate_initdata = "data";
$deflate_initflush_mode = ZLIB_NO_FLUSH;

$deflate_initreturn = deflate_add($deflate_initcontext, $deflate_initdata, $deflate_initflush_mode);

echo $deflate_initreturn . PHP_EOL;

$context = inflate_init($encoding);
$data = $deflate_initreturn;
$flush_mode = $deflate_initflush_mode;

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

var_dump($return);
x�
string(0) ""

4 · flush_mode · ZLIB_PARTIAL_FLUSH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$deflate_initcontext = deflate_init($encoding);
$deflate_initdata = "data";
$deflate_initflush_mode = ZLIB_PARTIAL_FLUSH;

$deflate_initreturn = deflate_add($deflate_initcontext, $deflate_initdata, $deflate_initflush_mode);

echo $deflate_initreturn . PHP_EOL;

$context = inflate_init($encoding);
$data = $deflate_initreturn;
$flush_mode = $deflate_initflush_mode;

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

var_dump($return);
x�JI,I
string(4) "data"

5 · flush_mode · ZLIB_SYNC_FLUSH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$deflate_initcontext = deflate_init($encoding);
$deflate_initdata = "data";
$deflate_initflush_mode = ZLIB_SYNC_FLUSH;

$deflate_initreturn = deflate_add($deflate_initcontext, $deflate_initdata, $deflate_initflush_mode);

echo $deflate_initreturn . PHP_EOL;

$context = inflate_init($encoding);
$data = $deflate_initreturn;
$flush_mode = $deflate_initflush_mode;

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

var_dump($return);
x�JI,I��
string(4) "data"

6 · flush_mode · ZLIB_FULL_FLUSH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$deflate_initcontext = deflate_init($encoding);
$deflate_initdata = "data";
$deflate_initflush_mode = ZLIB_FULL_FLUSH;

$deflate_initreturn = deflate_add($deflate_initcontext, $deflate_initdata, $deflate_initflush_mode);

echo $deflate_initreturn . PHP_EOL;

$context = inflate_init($encoding);
$data = $deflate_initreturn;
$flush_mode = $deflate_initflush_mode;

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

var_dump($return);
x�JI,I��
string(4) "data"

7 · flush_mode · ZLIB_FINISH

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$deflate_initcontext = deflate_init($encoding);
$deflate_initdata = "data";
$deflate_initflush_mode = ZLIB_FINISH;

$deflate_initreturn = deflate_add($deflate_initcontext, $deflate_initdata, $deflate_initflush_mode);

echo $deflate_initreturn . PHP_EOL;

$context = inflate_init($encoding);
$data = $deflate_initreturn;
$flush_mode = $deflate_initflush_mode;

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

var_dump($return);
x�KI,I�
string(4) "data"