PHP compresses html webpage code (clear spaces, line breaks, tabs, comment tags ). 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, remove PHP Compressed 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 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 ("\ r \ n", '', $ string); // clear line breaks
$ String = str_replace ("\ n", '', $ string); // clear the line break
$ 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, remove...