PHP compresses html webpage code. PHP compresses html webpage code (clear spaces, line breaks, tabs, comment tags ). There is a good way to compress HTML. compression of html is actually: clear line breaks, clear tabs, and compress html webpage code (clear spaces, line breaks, tabs, comment tags) in PHP ).
There is a good way to compress HTML. compression of html is actually: clear line breaks, clear tabs, and remove comment marks. The role it plays cannot be underestimated.
PHP compression HTML functions are now provided. Please try it. it feels good.
No nonsense. go directly to the code:
The code is as follows:
/**
* Html compression: clear line breaks, clear tabs, and remove comment tags
* @ Param $ string
* @ Return $ string after compression
**/
Function compress_html ($ string ){
$ String = str_replace ("rn", '', $ string); // clear the linefeed.
$ String = str_replace ("n", '', $ string); // clear the linefeed.
$ String = str_replace ("t", '', $ string); // clear the tab
$ Pattern = array (
"/> * ([^] *) * "/[S] + /",
"/ /",
"/"/",
"/"/",
"'/* [^ *] **/'"
);
$ Replace = array (
"> 1 <",
"",
"",
""",
""",
""
);
Return preg_replace ($ pattern, $ replace, $ string );
}
?>
Trim (clear space, line break, tab, comment mark ). There is a good way to compress HTML. compression of html is actually: clear line breaks, clear tabs, go...