-
-
- //String compression example
- $string =
- “http://bbs.it-home.org is php technical website.This website is personal website.php8848.com has many php and mysql or other IT knowledage articles,so welcome to php8848.com!please enjoy it! it's our honor if php8848 can help you !";
- $compressed = gzcompress($string);
- echo "Original size: ".strlen( $string)."n";
- /* prints
- Original size: 800
- */
- echo "Compressed size: ". strlen($compressed)."n";
- /* prints
- Compressed size: 418
- */
- // getting it back
- $original = gzuncompress($compressed); The compression rate of this operation can reach about 50%.
Copy code
In addition, the functions gzencode() and gzdecode() can achieve similar results by using different compression algorithms.
|