Home  >  Article  >  Backend Development  >  PHP detects whether the server supports gzip code_PHP tutorial

PHP detects whether the server supports gzip code_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:12:26857browse

This article will introduce you to a PHP test server that supports gzip code. Friends who need to know more can refer to it.

To check whether gzip is supported, you can use the function_exists function to determine whether your php environment supports ob_gzhandler. If it supports gzip, it supports gzip.

Write a function myself

The code is as follows
 代码如下 复制代码

if(extension_loaded('zlib')) {ob_start('ob_gzhandler');}
header('Content-type: text/html;charset=utf-8');
echo '如果您能看到这行文字就表示你的服务器支持gzip如果显示不了,就不支持。';
if(extension_loaded('zlib')) {ob_end_flush();}
?>

Copy code


if(extension_loaded('zlib')) {ob_start('ob_gzhandler');}

header('Content -type: text/html;charset=utf-8');

echo 'If you can see this line of text, it means that your server supports gzip. If it cannot be displayed, it does not support it. ';

if(extension_loaded('zlib')) {ob_end_flush();}
代码如下 复制代码

if(Extension_Loaded('zlib')) Ob_Start('ob_gzhandler');
Header("Content-type: text/html");
?>



php程序员的笔记


for($i=0;$i<10000;$i++){
echo 'Hello World!';
}
?>


if(Extension_Loaded('zlib')) Ob_End_Flush();
?>

?>

Also The way is to directly use , and then check whether gzip is turned on, or directly use the relevant webmaster tools Let me introduce one PHP implements gzip page compression
The code is as follows Copy code
if(Extension_Loaded('zlib')) Ob_Start('ob_gzhandler'); Header("Content-type: text/html") ; ?> php programmer's notes
for($i=0 ;$i<10000;$i++){ <🎜>echo 'Hello World!'; <🎜>} <🎜>?> < ;?PHP if(Extension_Loaded('zlib')) Ob_End_Flush(); ?> http://www.bkjia.com/PHPjc/444588.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444588.htmlTechArticleThis article introduces you to a PHP detection server that supports gzip code. Friends who need to know more may refer to it. To check whether gzip is supported, you can use the function_exists function to determine...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn