首页 > 代码库 > 如何进行PHP压缩(一点经验分享)

如何进行PHP压缩(一点经验分享)

<?php
echo "原来比率<br />";
$str = ‘{.....}‘;
echo strlen($str).‘<br />‘;
//压缩率居中
$compressed = gzcompress($str, 9);
echo ‘gzcompress:‘.strlen($compressed).‘,‘."<br />"; //gzuncompress($compressed)
 
 
//压缩率并列最高
$compressed = gzdeflate($str, 9);
echo ‘gzdeflate:‘.strlen($compressed).‘,‘."<br />"; //gzinflate($compressed)
 
$bzstr = bzcompress($str, 9);
echo ‘bzcompress:‘.strlen($bzstr).‘,‘."<br />"; //bzdecompress($bzstr)

如何进行PHP压缩(一点经验分享)