Home  >  Article  >  Backend Development  >  php compress CSS files

php compress CSS files

WBOY
WBOYOriginal
2016-07-25 08:42:371003browse

一次压缩多个CSS文件

  1. header('Content-type: text/css');
  2. ob_start("compress");
  3. function compress($buffer) {
  4. /* remove comments */
  5. $buffer = preg_replace('!/*[^*]**+([^/][^*]**+)*/!', '', $buffer);
  6. /* remove tabs, spaces, newlines, etc. */
  7. $buffer = str_replace(array("rn", "r", "n", "t", ' ', ' ', ' '), '', $buffer);
  8. return $buffer;
  9. }
  10. /* your css files */
  11. include('master.css');
  12. include('typography.css');
  13. include('grid.css');
  14. include('print.css');
  15. include('handheld.css');
  16. ob_end_flush();
复制代码

php, CSS


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn