This article will explain how PHP compresses CSS code.
Put the following code in the style.css.php file, and don't forget to include the CSS file you need:
<?phpheader (' content-type:text/css '); Ob_start ("compress"); function compress ($buffer) {/ * Remove comments */ $buffer = preg_replace ('!/\*[^*]*\*+ ([^/][^*]*\*+) */! ', ' ', $buffer); /* Remove tabs, spaces, newlines, etc. * /$buffer = str_replace (Array ("", "\ r", "\ n", "\ T", "',", " ) , ", $buffer); return $buffer;} /* Your CSS files */include (' Master.css '); include (' typography.css '); include (' grid.css '); include (' print.css '); Include (' handheld.css '); Ob_end_flush ();
The PHP file is then introduced in the HTML page where the style is introduced:
<link rel= "stylesheet" type= "text/css" media= "screen" href= "style.css.php"/>
This article explains the PHP compression CSS code method, more relevant content please focus on the PHP Chinese web.