admin 发表于 2015-3-18 20:01:49

php实现把html压缩输出(页面一行代码)

php实现把html压缩输出(页面一行代码)

函数代码:
<?php
$a=file_get_contents('html文件.html');
function Compress_Html($string){
    return trim(preg_replace(array("/> *([^ ]*) *</","/<!--[^!]*-->/","'/\*[^*]*\*/'","/\r\n/","/\n/","/\t/",'/>[ ]+</',"/\s(?=\s)/"),array(">\\1<",'','','','','','><',''),$string));
}

echo compress_html($a);
页: [1]
查看完整版本: php实现把html压缩输出(页面一行代码)