php 使用zlib压缩输出内容,提高网页打开速度

内容摘要
这篇文章主要为大家详细介绍了php 使用zlib压缩输出内容,提高网页打开速度,具有一定的参考价值,可以用来参考一下。

对php使用zlib压缩输出内容以提高网页打开速度对此感兴趣
文章正文

这篇文章主要为大家详细介绍了php 使用zlib压缩输出内容,提高网页打开速度,具有一定的参考价值,可以用来参考一下。

对php使用zlib压缩输出内容以提高网页打开速度对此感兴趣的朋友,看看idc笔记做的技术笔记!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<code class="php">
/**
 * php使用zlib压缩输出内容以提高网页打开速度
 *
 * @param
 * @arrange 512-笔记网: www.idcnote.com
 **/
<?PHP
if(extension_loaded('zlib')) ob_start('ob_gzhandler');
header("Content-type: text/html");
?>
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>如何使用zlib</title>
</head>
<body>
<?php
for($i=0;$i<100;$i++){
echo 'Hello World!';
}
?>
</body>
</html>
<?PHP
if(extension_loaded('zlib')) ob_end_flush();
?>
/***   来自php教程(www.idcnote.com)   ***/</code>

注:关于php 使用zlib压缩输出内容,提高网页打开速度的内容就先介绍到这里,更多相关文章的可以留意

代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!