gzuncompress

Uncompress a compressed string

Description

stringfalse gzuncompress(string $data, int $max_length = 0)

This function uncompress a compressed string.

Parameters

data

The data compressed by gzcompress.

max_length

The maximum length of data to decode.

Return Values

The original uncompressed data or false on error.

Errors/Exceptions

Throws a ValueError if max_length is negative. If data is not valid compressed data, or the uncompressed data is too large for max_length when it is not 0, an E_WARNING is raised and false is returned.

Changelog

Version Description
8.0.0 Now throws a ValueError if max_length is negative. Previously, an E_WARNING was raised and false was returned.

Examples

Example #1 gzuncompress example

<?php
$compressed   = gzcompress('Compress me', 9);
$uncompressed = gzuncompress($compressed);
echo $uncompressed;
?>

See Also

  • gzcompress
  • gzinflate
  • gzdeflate
  • gzencode