search
Homephp教程php手册php检测服务器是否支持gzip代码

php检测服务器是否支持gzip代码

Jun 13, 2016 am 11:28 AM
gzipphpintroducecodesupportarticleserverDetection

本文章给大家介绍一个php检测服务器是否支持gzip代码,有需要了解的朋友不防进入参考。

检测是否支持gzip 是可以利用function_exists函数来判断你的php环境支持ob_gzhandler不,如果支持就支持者gzip了。

自己写了一个函数

 代码如下 复制代码

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();}
?>


还一种办法就是直接利用,然后再看看是不是开启了gzip了,或直接利用相关的站长工具了

下面我来介绍一个PHP实现gzip页面压缩

 代码如下 复制代码

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



php程序员的笔记


for($i=0;$iecho 'Hello World!';
}
?>


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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.