天天看點

php壓縮頁面的html代碼一行顯示,把html代碼壓縮到一行

把html代碼壓縮到一行

liuqiong | 2014-07-08 10:55:26    閱讀:1503

php壓縮頁面的html代碼一行顯示,把html代碼壓縮到一行

釋出文章

function clear($str){

$search = array(

"''si",  // 去掉 javascript

"''si",  // 去掉css

"'

]*?>.*?'si",  // 去掉form

  // 去掉頭

// 去掉注釋

          // 去掉 HTML 标記

"'([\r\n])[\s]+'",                 // 去掉空白字元

"'([\r\n])+'",

// "'([\n])[\s]+'",

"'&(quot|#34);'i",                 // 替換 HTML 實體

"'&(amp|#38);'i",

"'&(lt|#60);'i",

"'&(gt|#62);'i",

"'&(nbsp|#160);'i",

"'&(iexcl|#161);'i",

"'&(cent|#162);'i",

"'&(pound|#163);'i",

"'&(copy|#169);'i",

"'(\d+);'e"

);

$replace = array ("");

$text = preg_replace ($search, $replace, $str);

return $text;

}

*部落格内容為網友個人釋出,僅代表部落客個人觀點,如有侵權請聯系從業人員删除。

參與讨論

請登入...

登入後參與讨論