PHP----实现压缩HTML

很多时候,我们在做优化处理的时候,会考虑压缩HTML,去掉HTML里面的空格和换行。

具体实现:

public function change(){
    echo "change";
    $url = "http://sanqi.e0yu.com/";
    $file = file_get_contents($url);
    $file = preg_replace("/	/","",$file);//将空格 替换为空
    $file = preg_replace("/
/","",$file);// 将换行 替换为空
    echo $file;
}
原文地址:https://www.cnblogs.com/e0yu/p/9120180.html