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

gzencode

Description

The gzencode of zlib for PHP creates a gzip compressed string.

Syntax

gzencode(
    string $data,
    int $level = -1,
    int $encoding = ZLIB_ENCODING_GZIP
): string|false

Parameters

data

The data to encode.

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 encoded string, or false if an error occurred.

Examples

1 · data

<?

$data = "data";

$return = gzencode($data);

echo $return;

?>
�KI,Ic��

2 · level · 0

<?

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

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

echo $return;

?>
���datac��

3 · level · 9

<?

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

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

echo $return;

?>
�KI,Ic��

4 · encoding · ZLIB_ENCODING_RAW

<?

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

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

echo $return;

?>
KI,I

5 · encoding · ZLIB_ENCODING_DEFLATE

<?

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

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

echo $return;

?>
x�KI,I�

6 · encoding · ZLIB_ENCODING_GZIP

<?

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

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

echo $return;

?>
�KI,Ic��
HomeMenu