PHP compression function (gzcompress gzuncompress) compresses strings

WBOY
Release: 2016-07-25 08:54:48
Original
1591 people have browsed it
  1. //String compression example
  2. $string =
  3. “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 !";
  4. $compressed = gzcompress($string);
  5. echo "Original size: ".strlen( $string)."n";
  6. /* prints
  7. Original size: 800
  8. */
  9. echo "Compressed size: ". strlen($compressed)."n";
  10. /* prints
  11. Compressed size: 418
  12. */
  13. // getting it back
  14. $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.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!