Laracon EU Online 2021

bzdecompress

(PHP 4 >= 4.0.4, PHP 5, PHP 7)

bzdecompressDecompresses bzip2 encoded data

Description

bzdecompress ( string $data [, bool $use_less_memory = FALSE ] ) : string|int|false

bzdecompress() decompresses the given string containing bzip2 encoded data.

Parameters

data

The string to decompress.

use_less_memory

If TRUE, an alternative decompression algorithm will be used which uses less memory (the maximum memory requirement drops to around 2300K) but works at roughly half the speed.

See the » bzip2 documentation for more information about this feature.

Return Values

The decompressed string, or FALSE or an error number if an error occurred.

Changelog

Version Description
8.0.0 The type of use_less_memory has been changed from int to bool. Previously, the default value was 0.

Examples

Example #1 Decompressing a String

<?php
$start_str 
"This is not an honest face?";
$bzstr bzcompress($start_str);

echo 
"Compressed String: ";
echo 
$bzstr;
echo 
"\n<br />\n";

$str bzdecompress($bzstr);
echo 
"Decompressed String: ";
echo 
$str;
echo 
"\n<br />\n";
?>

See Also

add a note add a note

User Contributed Notes 1 note

up
19
balint * atres / ath / cx
14 years ago
I spent a while to sort out some integer results of the bzdecompress, so maybe it'll be useful for somebody else also...
(Constants from the sources.)

#define BZ_OK                0
#define BZ_RUN_OK            1
#define BZ_FLUSH_OK          2
#define BZ_FINISH_OK         3
#define BZ_STREAM_END        4
#define BZ_SEQUENCE_ERROR    (-1)
#define BZ_PARAM_ERROR       (-2)
#define BZ_MEM_ERROR         (-3)
#define BZ_DATA_ERROR        (-4)
#define BZ_DATA_ERROR_MAGIC  (-5)
#define BZ_IO_ERROR          (-6)
#define BZ_UNEXPECTED_EOF    (-7)
#define BZ_OUTBUFF_FULL      (-8)
#define BZ_CONFIG_ERROR      (-9)
To Top