Possible Duplicate:
Which compression method to use in PHP?
It seems that PHP has many functions for making smaller strings out of strings. These functions are called inflate/deflate, encode/decode, and compress/uncompress. Some of them seem compatible with each other, as all are base on the zlib
library. What is the differences between them, and when to use each?
zlib (/ˈziːlɪb/ or "zeta-lib", /ˈziːtəˌlɪb/) is a software library used for data compression. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program.
In computing, Deflate (stylized as DEFLATE) is a lossless data compression file format that uses a combination of LZ77 and Huffman coding. It was designed by Phil Katz, for version 2 of his PKZIP archiving tool. Deflate was later specified in RFC 1951 (1996).
zlib was adapted from the gzip code. All of the mentioned patents have since expired. The zlib library supports Deflate compression and decompression, and three kinds of wrapping around the deflate streams.
The zlib compression format is free to use, and is not covered by any patent, so you can safely use it in commercial products as well. It is a lossless compression format (which means you don't lose any data between compression and decompression), and has the advantage of being portable across different platforms.
As stated in the function documentation linked to from the page in your link:
gzdeflate - use the 'clean' DEFLATE algorithm with the deflate data format.
gzcompress - use the ZLIB data format that add extra header and trailer data on the DEFLATE algorithm. As to RFC 1950 it "can be easily extended to use other compression methods".
gzencode - use the gzip application data format that includes some more header data over the ZLIB format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With