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

inflate_init

Description

The inflate_init of zlib for PHP initializes an incremental inflate context.

Syntax

inflate_init(
    int $encoding,
    array $options = []
): InflateContext|false

Parameters

encoding

One of the ZLIB_ENCODING_* constants.

ConstantDescription
ZLIB_ENCODING_RAWDEFLATE algorithm as per RFC 1951.
ZLIB_ENCODING_DEFLATEZLIB compression algorithm as per RFC 1950.
ZLIB_ENCODING_GZIPGZIP algorithm as per RFC 1952.

options

An associative array which may contain the following elements:

level

The compression level.

Range is from -1 to 9. Default is -1.

memory

The compression memory level.

Range is from 1 to 9. Default is 8.

window

The zlib window size (logarithmic).

Range is from 8 to 15. Default is 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 ZLIB_ENCODING_GZIP.

strategy

One of ZLIB_FILTERED, ZLIB_HUFFMAN_ONLY, ZLIB_RLE, ZLIB_FIXED or ZLIB_DEFAULT_STRATEGY (default).

dictionary

A string or an array of strings of the preset dictionary (default: no preset dictionary).

Return

Returns an inflate context resource (zlib.inflate) on success, or false on failure.

Examples

1 · encoding · ZLIB_ENCODING_RAW

<?

$encoding = ZLIB_ENCODING_RAW;

$return = inflate_init($encoding);

var_dump($return);

?>
object(InflateContext)#1 (0) {
}

2 · encoding · ZLIB_ENCODING_DEFLATE

<?

$encoding = ZLIB_ENCODING_DEFLATE;

$return = inflate_init($encoding);

var_dump($return);

?>
object(InflateContext)#1 (0) {
}

3 · encoding · ZLIB_ENCODING_GZIP

<?

$encoding = ZLIB_ENCODING_GZIP;

$return = inflate_init($encoding);

var_dump($return);

?>
object(InflateContext)#1 (0) {
}

4 · options

<?

$encoding = ZLIB_ENCODING_DEFLATE;
$options =
[
    "level" => -1,
    "memory" => 8,
    "window" => 15,
    "strategy" => ZLIB_DEFAULT_STRATEGY,
    "dictionary" => "",
];

$return = inflate_init($encoding, $options);

var_dump($return);

?>
object(InflateContext)#1 (0) {
}
HomeMenu