GZDEFLATE(3) 1 GZDEFLATE(3)gzdeflate - Deflate a stringSYNOPSIS
string gzdeflate (string $data, [int $level = -1], [int $encoding = ZLIB_ENCODING_RAW])
DESCRIPTION
This function compresses the given string using the DEFLATE data format.
For details on the DEFLATE compression algorithm see the document "DEFLATE Compressed Data Format Specification version 1.3" (RFC 1951).
PARAMETERS
o $data
- The data to deflate.
o $level
- The level of compression. Can be given as 0 for no compression up to 9 for maximum compression. If not given, the default com-
pression level will be the default compression level of the zlib library.
o $encoding
- One of ZLIB_ENCODING_* constants.
RETURN VALUES
The deflated string or FALSE if an error occurred.
EXAMPLES
Example #1
gzdeflate(3) example
<?php
$compressed = gzdeflate('Compress me', 9);
echo $compressed;
?>
CHANGELOG
+--------+-----------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+-----------------------------+
| 5.4.0 | |
| | |
| | Added $encoding parameter. |
| | |
+--------+-----------------------------+
SEE ALSO gzinflate(3), gzcompress(3), gzuncompress(3), gzencode(3).
PHP Documentation Group GZDEFLATE(3)
Check Out this Related Man Page
GZENCODE(3) 1 GZENCODE(3)gzencode - Create a gzip compressed stringSYNOPSIS
string gzencode (string $data, [int $level = -1], [int $encoding_mode = FORCE_GZIP])
DESCRIPTION
This function returns a compressed version of the input $data compatible with the output of the gzip program.
For more information on the GZIP file format, see the document: GZIP file format specification version 4.3 (RFC 1952).
PARAMETERS
o $data
- The data to encode.
o $level
- The level of compression. Can be given as 0 for no compression up to 9 for maximum compression. If not given, the default com-
pression level will be the default compression level of the zlib library.
o $encoding_mode
- The encoding mode. Can be FORCE_GZIP (the default) or FORCE_DEFLATE. Prior to PHP 5.4.0, using FORCE_DEFLATE results in a stan-
dard zlib deflated string (inclusive zlib headers) after a gzip file header but without the trailing crc32 checksum. In PHP 5.4.0
and later, FORCE_DEFLATE generates RFC 1950 compliant output, consisting of a zlib header, the deflated data, and an Adler check-
sum.
RETURN VALUES
The encoded string, or FALSE if an error occurred.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.4.0 | |
| | |
| | |
| | FORCE_DEFLATE now generates RFC 1950 compliant |
| | output. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
The resulting data contains the appropriate headers and data structure to make a standard .gz file, e.g.:
Example #1
Creating a gzip file
<?php
$data = implode("", file("bigfile.txt"));
$gzdata = gzencode($data, 9);
$fp = fopen("bigfile.txt.gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
?>
SEE ALSO gzdecode(3), gzdeflate(3), gzinflate(3), gzuncompress(3), gzcompress(3), ZLIB Compressed Data Format Specification (RFC 1950) .
PHP Documentation Group GZENCODE(3)
I have heard that bz2 compression a relatively new compression encoding algorithm, far superior to tar and gz. I also remember that I downloaded a FreeBSD LiveCD a while back that was only a couple hundred megs instead of the usual 650ish using bz2 - big difference, I'd say. But to the point, what... (4 Replies)
Hi,
I have a file with data as follows:
324dsadfasfgf23<xmlsssssssssssssssssssssssssssssssssssssss<fdf>dfsdf>
i need all the data followed by the string <xml?
Is it possible to retrieve it? (1 Reply)
I have noticed while Compressing certain .tar files using Compress.exe, sometimes the Compressed version is bigger than the original which causes the Compressed version to be deleted. Is this normal behavior? (5 Replies)
Hi all,
I'm writing a program in bourne shell that compresses a file 3 different ways then displays a table of data with the compression type, original file size, compressed size and compression ratio. I've written most of it but reached 2 problems that won't allow me to finish it correctly.
The... (2 Replies)