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

gzdeflate

Description

The gzdeflate of zlib for PHP deflates a string.

Syntax

gzdeflate(
    string $data,
    int $level = -1,
    int $encoding = ZLIB_ENCODING_RAW
): string|false

Parameters

data

The data to deflate.

level

The level of compression.

Can be given as 0 for no compression up to 9 for maximum compression. If -1 is used, the default compression of the zlib library is used which is 6.

encoding

The encoding mode.

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.

Return

Returns the deflated string or false if an error occurred.

Examples

1 · data

<?

$data = "data";

$return = gzdeflate($data);

echo $return;

?>
KI,I

2 · level · 0

<?

$data = "data";
$level = 0;

$return = gzdeflate($data, $level);

echo $return;

?>
��data

3 · level · 9

<?

$data = "data";
$level = 9;

$return = gzdeflate($data, $level);

echo $return;

?>
KI,I

4 · encoding · ZLIB_ENCODING_RAW

<?

$data = "data";
$level = -1;
$encoding = ZLIB_ENCODING_RAW;

$return = gzdeflate($data, $level, $encoding);

echo $return;

?>
KI,I

5 · encoding · ZLIB_ENCODING_DEFLATE

<?

$data = "data";
$level = -1;
$encoding = ZLIB_ENCODING_DEFLATE;

$return = gzdeflate($data, $level, $encoding);

echo $return;

?>
x�KI,I�

6 · encoding · ZLIB_ENCODING_GZIP

<?

$data = "data";
$level = -1;
$encoding = ZLIB_ENCODING_GZIP;

$return = gzdeflate($data, $level, $encoding);

echo $return;

?>
�KI,Ic��
HomeMenu