首頁  >  文章  >  後端開發  >  php壓縮和解壓縮字串的程式碼

php壓縮和解壓縮字串的程式碼

WBOY
WBOY原創
2016-07-25 08:44:171037瀏覽

下面php代码通过gzcompress和gzuncompress压缩和解压缩字符串,可以设定压缩级别

  1. $str = 'Hello I am a very very very very long string';
  2. $compressed = gzcompress($str, 9);//压缩级别为9
  3. $uncompressed = gzuncompress($compressed);
  4. echo $str, "n";
  5. echo $uncompressed, "n";
  6. echo base64_encode($compressed), "n";
  7. echo bin2hex($compressed), "n";
  8. echo urlencode($compressed), "n";
复制代码

php


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn