gzdeflate()
gzdeflate() — Deflate a string.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
This function compresses the given string using the DEFLATE data format.
Signature
gzdeflate(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_RAW): string|false
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $data | string | The data to deflate. |
| $level | int | The level of compression. Can be given as 0 for no compression up to 9 for maximum compression. If not given, the default compression level will be the default compression level of the zlib library. |
| $encoding | int | One of ZLIB_ENCODING_* constants. |
Return value
The deflated string or false if an error occurred.
Example
A runnable snippet:
$compressed = gzdeflate('Compress me', 9); echo $compressed;
See also
gzinflate(), gzcompress(), gzuncompress(), gzencode()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page gzdeflate() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.