This script radically reduces loading time by sending HTML in a compressed format. When I use it, I get an error on line 26, can anyone help?
<?php
/* Put this code in a file called gzdoc.php.
Then in your pages put <? include "gzdoc.php"; ?> right at the top, before everything else.
Then at the bottom put <? gzdocout(); ?>
*/
ob_start();
ob_implicit_flush(0);
function_CheckCanGzip(){
global_$HTTP_ACCEPT_ENCODING;____
__if_(headers_sent()_||_connection_timeout()_||_connection_aborted()){_
________return_0;_
____}_
____if_(strpos($HTTP_ACCEPT_ENCODING,_'x-gzip')_!==_false)_return_"x-gzip";_
____if_(strpos($HTTP_ACCEPT_ENCODING,'gzip')_!==_false)_return_"gzip";_
____return_0;_
}_
/* $level = compression level 0-9, 0=none, 9=max */
function_GzDocOut($level=6,$debug=0){_
____$ENCODING_=_CheckCanGzip();_
____if_($ENCODING){_
________$Contents_=_ob_get_contents();_
________ob_end_clean();_
________if_($debug){_
____________$s_=_"<p>Not compress length: ".strlen($Contents);_
____________$s_.=_"<br>Compressed length: ".strlen(gzcompress($Contents,$level));
____________$Contents_.=_$s;_
________}
________header("Content-Encoding:_$ENCODING");______
________print_"\x1f\x8b\x08\x00\x00\x00\x00\x00";_
________$Size_=_strlen($Contents);_
________$Crc_=_crc32($Contents);_
________$Contents_=_gzcompress($Contents,$level);_
________$Contents_=_substr($Contents,_0,_strlen($Contents)_-_4);_
________print_$Contents;_
________print_pack('V',$Crc);_
________print_pack('V',$Size);_
________exit;_
____}else{_
________ob_end_flush();_
________exit;_
____}_
}_
?>
😕the extra _s are just spaces or mean nothing