Skip to content

Instantly share code, notes, and snippets.

@imlinus
Last active December 12, 2016 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imlinus/6671d49b7d79f885a4884c202210bd19 to your computer and use it in GitHub Desktop.
Save imlinus/6671d49b7d79f885a4884c202210bd19 to your computer and use it in GitHub Desktop.
php
<?php
function compress_page($buffer) {
$search = array("/<!–\{(.*?)\}–>|<!–(.*?)–>|[\t\r\n]|<!–|–>|\/\/ <!–|\/\/ –>|<!\[CDATA\[|\/\/ \]\]>|\]\]>|\/\/\]\]>|\/\/<!\[CDATA\[/" => "");
$buffer = preg_replace(array_keys($search), array_values($search), $buffer);
return $buffer;
}
ob_start('compress_page');
// Page here
ob_end_flush();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment