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