Example 1 (using PHP’s built-in compression function):
Copy code The code is as follows:
if(Extension_Loaded('zlib')) Ob_Start('ob_gzhandler');
Header("Content-type: text/html");
?>
Untitled Document
for($i=0;$i<10000;$i++){
echo 'Hello World!';
}
?>
html>
if(Extension_Loaded('zlib')) Ob_End_Flush();
?>
Example 2 (from Write function):
Copy code The code is as follows:
Untitled Document
< ;/body>
ob_end_flush();
//Compression function
function ob_gzip($content){
if(!headers_sent ()&&extension_loaded("zlib")&&strstr($_SERVER["HTTP_ACCEPT_ENCODING"],"gzip")){
$content = gzencode($content,9);
header("Content-Encoding: gzip" );
header("Vary: Accept-Encoding");
header("Content-Length: ".strlen($content));
}
return $content;
}
?>
http://www.bkjia.com/PHPjc/327532.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327532.htmlTechArticleExample 1 (using PHP’s built-in compression function): Copy the code as follows: ?PHP if(Extension_Loaded('zlib ')) Ob_Start('ob_gzhandler'); Header("Content-type: text/html"); ? !DOCTYPE h...