php 提供的字符串壓縮方法有
1.gzcomPRess — Compress a string
This function compress the given string using the ZLIB data format.
2.gzencode — Create a gzip compressed string
This function returns a compressed version of the input data compatible with the output of the gzip program
3.gzdeflate — Deflate a string
This function compress the given string using the DEFLATE data format.
4.bzcompress — 把一個字符串壓縮成 bzip2 編碼數據
bzcompress() 壓縮了指定的字符串并以 bzip2 編碼返回數據。
下面對這四種方法進行壓縮比較,分別進行中文和英文數字的壓縮
[php] view plain copygzcompress 速度最快,壓縮比率較高。
gzdeflate 壓縮比率最高,速度稍慢于gzcompress
gzencode 與 gzdeflate 比較接近,gzdeflate稍有優勢
bzcompress 速度最慢,壓縮比率最慢。
因此建議使用 gzcompress 和 gzdeflate。
新聞熱點
疑難解答
圖片精選