File size: 818B
<?php
error_reporting(0);
$step = 5;
function compress_output_x_gzip($output){
global $step;
$size = strlen($output);
$crc = crc32($output);
$output = gzcompress($output, $step);
$output = substr($output, 0, strlen($output) - 4);
return "\x1f\x8b\x08\x00\x00\x00\x00\x00".$output.pack('V',$crc).pack('V',$size);
}
$method = 'x-gzip';
header('Content-Encoding: x-gzip');
ob_start('compress_output_x_gzip');
ob_implicit_flush(0);
// Инфа о проценте сжатия и др.
function info_compress()
{
global $method, $step;
$contents = ob_get_contents();
// Сколько весит исходная страница
$in = strlen($contents);
$out = strlen(gzcompress($contents, $step));
print 'x-gzip: '.round(100-(100/($in/$out)),1).' %<br/>';
return;
}
?>