本文實(shí)例講述了php壓縮和解壓縮字符串的方法。分享給大家供大家參考。具體如下:
下面php代碼通過(guò)gzcompress和gzuncompress壓縮和解壓縮字符串,可以設(shè)定壓縮級(jí)別
$str = 'Hello I am a very very very very long string';
$compressed = gzcompress($str, 9);//壓縮級(jí)別為9
$uncompressed = gzuncompress($compressed);
echo $str, "\n";
echo $uncompressed, "\n";
echo base64_encode($compressed), "\n";
echo bin2hex($compressed), "\n";
echo urlencode($compressed), "\n";
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
更多信息請(qǐng)查看IT技術(shù)專(zhuān)欄