当前位置: 编程技术>php
本页文章导读:
▪基于php冒泡排序算法的深入理解
交换排序的基本思想:两两比较待排序的数据,如果发生逆序,则交换之,直到全部数据都排好序为止。•冒泡排序的基本思想:1.从后往前,扫描所有的数据,如果相邻的两个数发生逆序.........
▪深入apache host的配置详解
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.127.0.0.1 DocumentRoot "D:/dev/Apache2.2/docs/dummy-host.127.0.0.1" ServerName dummy-host.127.0.0.1 ServerAlias www.dummy-host.127.0.0.1 ErrorLog "logs/dummy-hos.........
▪探讨如何在PHP开启gzip页面压缩实例
示例一(用php的内置压缩函数): 代码如下:<?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/T.........
[1]基于php冒泡排序算法的深入理解
来源: 互联网 发布时间: 2013-11-30
交换排序的基本思想:两两比较待排序的数据,如果发生逆序,则交换之,直到全部数据都排好序为止。
•冒泡排序的基本思想:
1.从后往前,扫描所有的数据,如果相邻的两个数发生逆序,则互换。--第1趟冒泡
2.从后往前,扫描最后一个到第2个数据,如果相邻的两个数发生逆序,则互换。--第2趟冒泡
3.如此依次进行,直到进行n-1趟冒泡,或者在某趟冒泡中,没有逆序的情况即可提前结束。
代码如下:
<script>
var arr = [15,8,7,9,10,0];
var _len = arr.length;
alert("排序之前:"+arr);
var exchange=0;
var temp = 0;
for(var i=0; i<arr.length;i++)
{
exchange=0;
for(var j=arr.length;j>=i;j--)
{
if(arr[j] < arr[i])
{
temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
exchange = 1;
}
}
if(exchange == 0)
{
break;
}
}
alert("排序之后:"+ arr);
</script>
[2]深入apache host的配置详解
来源: 互联网 发布时间: 2013-11-30
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.127.0.0.1
DocumentRoot "D:/dev/Apache2.2/docs/dummy-host.127.0.0.1"
ServerName dummy-host.127.0.0.1
ServerAlias www.dummy-host.127.0.0.1
ErrorLog "logs/dummy-host.127.0.0.1-error.log"
CustomLog "logs/dummy-host.127.0.0.1-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.127.0.0.1
DocumentRoot "D:/dev/Apache2.2/docs/dummy-host2.127.0.0.1"
ServerName dummy-host2.127.0.0.1
ErrorLog "logs/dummy-host2.127.0.0.1-error.log"
CustomLog "logs/dummy-host2.127.0.0.1-access.log" common
</VirtualHost>
ServerAdmin webmaster@dummy-host.127.0.0.1
DocumentRoot "D:/dev/Apache2.2/docs/dummy-host.127.0.0.1"
ServerName dummy-host.127.0.0.1
ServerAlias www.dummy-host.127.0.0.1
ErrorLog "logs/dummy-host.127.0.0.1-error.log"
CustomLog "logs/dummy-host.127.0.0.1-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.127.0.0.1
DocumentRoot "D:/dev/Apache2.2/docs/dummy-host2.127.0.0.1"
ServerName dummy-host2.127.0.0.1
ErrorLog "logs/dummy-host2.127.0.0.1-error.log"
CustomLog "logs/dummy-host2.127.0.0.1-access.log" common
</VirtualHost>
[3]探讨如何在PHP开启gzip页面压缩实例
来源: 互联网 发布时间: 2013-11-30
示例一(用php的内置压缩函数):
<?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=gb2312" />
<title>无标题文档</title>
</head>
<body>
<?php
for($i=0;$i<10000;$i++){
echo 'Hello World!';
}
?>
</body>
</html>
<?PHP
if(Extension_Loaded('zlib')) Ob_End_Flush();
?>
示例二(自写函数):
<?php ob_start('ob_gzip'); ?>
<!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=gb2312" />
<title>无标题文档</title>
</head>
<body>
</body>
</html>
<?php
ob_end_flush();
//压缩函数
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;
}
?>
代码如下:
<?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=gb2312" />
<title>无标题文档</title>
</head>
<body>
<?php
for($i=0;$i<10000;$i++){
echo 'Hello World!';
}
?>
</body>
</html>
<?PHP
if(Extension_Loaded('zlib')) Ob_End_Flush();
?>
示例二(自写函数):
代码如下:
<?php ob_start('ob_gzip'); ?>
<!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=gb2312" />
<title>无标题文档</title>
</head>
<body>
</body>
</html>
<?php
ob_end_flush();
//压缩函数
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;
}
?>
最新技术文章: