Return to Snippet

Revision: 55899
at February 27, 2012 22:35 by soup


Initial Code
<?php
  header('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('style.css');
#  include('print.css');
#  include('handheld.css');

  ob_end_flush();
?>

Initial URL


Initial Description
Use always

Initial Title
Compress & minify CSS with php

Initial Tags
css, php

Initial Language
PHP