萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php壓縮和解壓縮字符串的方法

php壓縮和解壓縮字符串的方法

 本文實例講述了php壓縮和解壓縮字符串的方法。分享給大家供大家參考。具體如下:

下面php代碼通過gzcompress和gzuncompress壓縮和解壓縮字符串,可以設定壓縮級別

$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程序設計有所幫助。

copyright © 萬盛學電腦網 all rights reserved