﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>PHP博客-为了忘却的纪念   $bestmost-&gt;save("多多益善")</title><link>http://www.phpweblog.net/fuyongjie/</link><description>言己及众</description><language>zh-cn</language><lastBuildDate>Fri, 19 Mar 2010 12:42:32 GMT</lastBuildDate><pubDate>Fri, 19 Mar 2010 12:42:32 GMT</pubDate><ttl>60</ttl><item><title>PCAS省、市、地区联动选择JS封装类</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/11/03/6909.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Tue, 03 Nov 2009 09:49:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/11/03/6909.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6909.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/11/03/6909.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6909.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6909.html</trackback:ping><description><![CDATA[<pre>/* PCAS (Province City Area Selector 省、市、地区联动选择JS封装类) Ver 2.01 数据压缩完整版 *\<br /><br />　制作时间:2005-12-30<br />　更新时间:2006-01-24<br />　数据修正:2006-08-17<br />　文档大小:18KB<br />　演示地址:<a href="http://www.popub.net/script/PCAS.html">http://www.popub.net/script/PCAS.html</a><br />　下载地址:<a href="http://www.popub.net/script/PCASClass.js"><font color="red">http://www.popub.net/script/PCASClass.js</font></a><br />　应用说明:页面包含&lt;script type="text/javascript" src="PCASClass.js"&gt;&lt;/script&gt;<br />	省市联动<br />		new PCAS("Province","City")<br />		new PCAS("Province","City","吉林省")<br />		new PCAS("Province","City","吉林省","吉林市")<br />	省市地区联动<br />		new PCAS("Province","City","Area")<br />		new PCAS("Province","City","Area","吉林省")<br />		new PCAS("Province","City","Area","吉林省","松原市")<br />		new PCAS("Province","City","Area","吉林省","松原市","宁江区")<br />	省、市、地区对象取得的值均为实际值。<br />	注：省、市、地区提示信息选项的值为""(空字符串)<br /><br />　感谢<br />　　　网友418528#gmail.com对数据进行的核实工作 2006-08-07<br /><br />\*** 程序制作/版权所有:崔永祥(333) E-Mail:zhadan007@21cn.com 网址:http://www.popub.net ***/<br /></pre>
		<script language="javascript" src="http://www.popub.net/script/PCASClass.js">
		</script>
		<b>MSClass (Class Of Marquee Scroll通用不间断滚动JS封装类) Ver 1.6:</b> <a href="http://www.popub.net/script/msclass.html"><font color="red">演示及下载</font></a><br /><br /><br /><b>省、市、地区联动选择压缩版应用实例演示:</b> <a href="http://www.popub.net/script/PCASClass.js"><font color="red">下载</font></a><a href="http://www.popub.net/script/pcasunzip.html"><font color="red">下载未压缩版</font></a><br /><br /><fieldset style="padding: 5px;"><legend>省市联动</legend>
出生地：<select name="P1"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="C1"><option value="">--请选择城市--</option></select><br />
所在地：<select name="P2"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="C2"><option value="长春市">长春市</option><option value="吉林市">吉林市</option><option value="四平市">四平市</option><option value="辽源市">辽源市</option><option value="通化市">通化市</option><option value="白山市">白山市</option><option value="松原市">松原市</option><option value="白城市">白城市</option><option value="延边朝鲜族自治州">延边朝鲜族自治州</option></select><br />
工作地：<select name="P3"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="C3"><option value="南京市">南京市</option><option value="无锡市">无锡市</option><option value="徐州市">徐州市</option><option value="常州市">常州市</option><option value="苏州市">苏州市</option><option value="南通市">南通市</option><option value="连云港市">连云港市</option><option value="淮安市">淮安市</option><option value="盐城市">盐城市</option><option value="扬州市">扬州市</option><option value="镇江市">镇江市</option><option value="泰州市">泰州市</option><option value="宿迁市">宿迁市</option></select><br /></fieldset><br /><br /><fieldset style="padding: 5px;"><legend>省市地区联动</legend>
出　　 生 　地：<select name="province"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="city"><option value="广州市">广州市</option><option value="韶关市">韶关市</option><option value="深圳市">深圳市</option><option value="珠海市">珠海市</option><option value="汕头市">汕头市</option><option value="佛山市">佛山市</option><option value="江门市">江门市</option><option value="湛江市">湛江市</option><option value="茂名市">茂名市</option><option value="肇庆市">肇庆市</option><option value="惠州市">惠州市</option><option value="梅州市">梅州市</option><option value="汕尾市">汕尾市</option><option value="河源市">河源市</option><option value="阳江市">阳江市</option><option value="清远市">清远市</option><option value="东莞市">东莞市</option><option value="中山市">中山市</option><option value="潮州市">潮州市</option><option value="揭阳市">揭阳市</option><option value="云浮市">云浮市</option></select><select name="area"><option value="市辖区">市辖区</option><option value="荔湾区">荔湾区</option><option value="越秀区">越秀区</option><option value="海珠区">海珠区</option><option value="天河区">天河区</option><option value="白云区">白云区</option><option value="黄埔区">黄埔区</option><option value="番禺区">番禺区</option><option value="花都区">花都区</option><option value="南沙区">南沙区</option><option value="萝岗区">萝岗区</option><option value="增城市">增城市</option><option value="从化市">从化市</option></select><br />
户 口 所 在 地：<select name="province1"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="city1"><option value="长春市">长春市</option><option value="吉林市">吉林市</option><option value="四平市">四平市</option><option value="辽源市">辽源市</option><option value="通化市">通化市</option><option value="白山市">白山市</option><option value="松原市">松原市</option><option value="白城市">白城市</option><option value="延边朝鲜族自治州">延边朝鲜族自治州</option></select><select name="area1"><option value="市辖区">市辖区</option><option value="昌邑区">昌邑区</option><option value="龙潭区">龙潭区</option><option value="船营区">船营区</option><option value="丰满区">丰满区</option><option value="永吉县">永吉县</option><option value="蛟河市">蛟河市</option><option value="桦甸市">桦甸市</option><option value="舒兰市">舒兰市</option><option value="磐石市">磐石市</option></select><br />
工 作 所 在 地：<select name="province2"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="city2"><option value="南京市">南京市</option><option value="无锡市">无锡市</option><option value="徐州市">徐州市</option><option value="常州市">常州市</option><option value="苏州市">苏州市</option><option value="南通市">南通市</option><option value="连云港市">连云港市</option><option value="淮安市">淮安市</option><option value="盐城市">盐城市</option><option value="扬州市">扬州市</option><option value="镇江市">镇江市</option><option value="泰州市">泰州市</option><option value="宿迁市">宿迁市</option></select><select name="area2"><option value="市辖区">市辖区</option><option value="沧浪区">沧浪区</option><option value="平江区">平江区</option><option value="金阊区">金阊区</option><option value="虎丘区">虎丘区</option><option value="吴中区">吴中区</option><option value="相城区">相城区</option><option value="常熟市">常熟市</option><option value="张家港市">张家港市</option><option value="昆山市">昆山市</option><option value="吴江市">吴江市</option><option value="太仓市">太仓市</option></select><br /><br />
无　　默　　认：<select name="province3"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="city3"><option value="广州市">广州市</option><option value="韶关市">韶关市</option><option value="深圳市">深圳市</option><option value="珠海市">珠海市</option><option value="汕头市">汕头市</option><option value="佛山市">佛山市</option><option value="江门市">江门市</option><option value="湛江市">湛江市</option><option value="茂名市">茂名市</option><option value="肇庆市">肇庆市</option><option value="惠州市">惠州市</option><option value="梅州市">梅州市</option><option value="汕尾市">汕尾市</option><option value="河源市">河源市</option><option value="阳江市">阳江市</option><option value="清远市">清远市</option><option value="东莞市">东莞市</option><option value="中山市">中山市</option><option value="潮州市">潮州市</option><option value="揭阳市">揭阳市</option><option value="云浮市">云浮市</option></select><select name="area3"><option value="市辖区">市辖区</option><option value="荔湾区">荔湾区</option><option value="越秀区">越秀区</option><option value="海珠区">海珠区</option><option value="天河区">天河区</option><option value="白云区">白云区</option><option value="黄埔区">黄埔区</option><option value="番禺区">番禺区</option><option value="花都区">花都区</option><option value="南沙区">南沙区</option><option value="萝岗区">萝岗区</option><option value="增城市">增城市</option><option value="从化市">从化市</option></select><br />
默　　认　　省：<select name="province4"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="city4"><option value="南京市">南京市</option><option value="无锡市">无锡市</option><option value="徐州市">徐州市</option><option value="常州市">常州市</option><option value="苏州市">苏州市</option><option value="南通市">南通市</option><option value="连云港市">连云港市</option><option value="淮安市">淮安市</option><option value="盐城市">盐城市</option><option value="扬州市">扬州市</option><option value="镇江市">镇江市</option><option value="泰州市">泰州市</option><option value="宿迁市">宿迁市</option></select><select name="area4"><option value="市辖区">市辖区</option><option value="玄武区">玄武区</option><option value="白下区">白下区</option><option value="秦淮区">秦淮区</option><option value="建邺区">建邺区</option><option value="鼓楼区">鼓楼区</option><option value="下关区">下关区</option><option value="浦口区">浦口区</option><option value="栖霞区">栖霞区</option><option value="雨花台区">雨花台区</option><option value="江宁区">江宁区</option><option value="六合区">六合区</option><option value="溧水县">溧水县</option><option value="高淳县">高淳县</option></select><br />
默　认　省　市：<select name="province5"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="city5"><option value="南京市">南京市</option><option value="无锡市">无锡市</option><option value="徐州市">徐州市</option><option value="常州市">常州市</option><option value="苏州市">苏州市</option><option value="南通市">南通市</option><option value="连云港市">连云港市</option><option value="淮安市">淮安市</option><option value="盐城市">盐城市</option><option value="扬州市">扬州市</option><option value="镇江市">镇江市</option><option value="泰州市">泰州市</option><option value="宿迁市">宿迁市</option></select><select name="area5"><option value="市辖区">市辖区</option><option value="沧浪区">沧浪区</option><option value="平江区">平江区</option><option value="金阊区">金阊区</option><option value="虎丘区">虎丘区</option><option value="吴中区">吴中区</option><option value="相城区">相城区</option><option value="常熟市">常熟市</option><option value="张家港市">张家港市</option><option value="昆山市">昆山市</option><option value="吴江市">吴江市</option><option value="太仓市">太仓市</option></select><br />
默 认 省 市 区：<select name="province6"><option value="">--请选择省份--</option><option value="北京市">北京市</option><option value="天津市">天津市</option><option value="河北省">河北省</option><option value="山西省">山西省</option><option value="内蒙古自治区">内蒙古自治区</option><option value="辽宁省">辽宁省</option><option value="吉林省">吉林省</option><option value="黑龙江省">黑龙江省</option><option value="上海市">上海市</option><option value="江苏省">江苏省</option><option value="浙江省">浙江省</option><option value="安徽省">安徽省</option><option value="福建省">福建省</option><option value="江西省">江西省</option><option value="山东省">山东省</option><option value="河南省">河南省</option><option value="湖北省">湖北省</option><option value="湖南省">湖南省</option><option value="广东省">广东省</option><option value="广西壮族自治区">广西壮族自治区</option><option value="海南省">海南省</option><option value="重庆市">重庆市</option><option value="四川省">四川省</option><option value="贵州省">贵州省</option><option value="云南省">云南省</option><option value="西藏自治区">西藏自治区</option><option value="陕西省">陕西省</option><option value="甘肃省">甘肃省</option><option value="青海省">青海省</option><option value="宁夏回族自治区">宁夏回族自治区</option><option value="新疆维吾尔自治区">新疆维吾尔自治区</option><option value="香港特别行政区">香港特别行政区</option><option value="澳门特别行政区">澳门特别行政区</option><option value="台湾省">台湾省</option><option value="其它">其它</option></select><select name="city6"><option value="南京市">南京市</option><option value="无锡市">无锡市</option><option value="徐州市">徐州市</option><option value="常州市">常州市</option><option value="苏州市">苏州市</option><option value="南通市">南通市</option><option value="连云港市">连云港市</option><option value="淮安市">淮安市</option><option value="盐城市">盐城市</option><option value="扬州市">扬州市</option><option value="镇江市">镇江市</option><option value="泰州市">泰州市</option><option value="宿迁市">宿迁市</option></select><select name="area6"><option value="市辖区">市辖区</option><option value="沧浪区">沧浪区</option><option value="平江区">平江区</option><option value="金阊区">金阊区</option><option value="虎丘区">虎丘区</option><option value="吴中区">吴中区</option><option value="相城区">相城区</option><option value="常熟市">常熟市</option><option value="张家港市">张家港市</option><option value="昆山市">昆山市</option><option value="吴江市">吴江市</option><option value="太仓市">太仓市</option></select><br /></fieldset><script language="javascript" defer="defer"><![CDATA[
new PCAS("P1","C1");
new PCAS("P2","C2","吉林省");
new PCAS("P3","C3","江苏省","苏州市");

new PCAS("province","city","area","吉林省","白城市","大安市");
new PCAS("province1","city1","area1","吉林省","吉林市","龙潭区");
new PCAS("province2","city2","area2","江苏省","苏州市","沧浪区");

new PCAS("province3","city3","area3");
new PCAS("province4","city4","area4","江苏省");
new PCAS("province5","city5","area5","江苏省","苏州市");
new PCAS("province6","city6","area6","江苏省","苏州市","沧浪区");
]]&gt;</script><br /><script language="javascript" type="text/javascript" src="http://js.users.51.la/3287800.js"></script>http://www.91php.cn/rewrite.php/read-3.html
<img style="width: 0px; height: 0px;" src="http://web.51.la/go.asp?svid=31&amp;id=3287800&amp;tpages=1&amp;ttimes=1&amp;tzone=8&amp;tcolor=32&amp;sSize=1366,768&amp;referrer=http%3A//www.91php.cn/rewrite.php/read-3.html&amp;vpage=http%3A//www.popub.net/script/PCAS.html" /><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6909.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-11-03 17:49 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/11/03/6909.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>按钮不能获得焦点的一个解惑</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/09/12/6878.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Sat, 12 Sep 2009 07:56:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/09/12/6878.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6878.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/09/12/6878.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6878.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6878.html</trackback:ping><description><![CDATA[<p>【友情链接：<a title="天津打折促销购物" href="http://www.tjcuxiao.com" target="_blank">http://www.tjcuxiao.com</a> 和<a title="目击者 肇事 行凶 腐败 贪污" href="http://www.mujiz.cn" target="_blank">http://www.mujiz.cn</a>】<br />在我们用div模拟生成alert提示框时，这个对话框里的“确定”得不到焦点，那么就不能通过ENTER键去取消这个alert的提示框，一开始我们尝试用$('#popDivBtnWin')[0].focus()la来打算使其获得焦点，但是并未成功，很费解。后来将这个$('#popDivBtnWin')[0].focus()给写成setTimeout("$('#popDivBtnWin')[0].focus()",0);就可以了。</p><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6878.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-09-12 15:56 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/09/12/6878.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP程序漏洞产生的原因和防范方法</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/08/20/6857.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Thu, 20 Aug 2009 00:52:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/08/20/6857.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6857.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/08/20/6857.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6857.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6857.html</trackback:ping><description><![CDATA[【友情链接：<a title="天津打折促销购物" href="http://www.tjcuxiao.com" target="_blank">http://www.tjcuxiao.com</a> 和<a title="目击者 肇事 行凶 腐败 贪污" href="http://www.mujiz.cn" target="_blank">http://www.mujiz.cn</a>】<br /><br /><strong>滥用include <br /><br /></strong>1.漏洞原因： <br /><br />Include是编写PHP网站中最常用的函数，并且支持相对路径。有很多PHP脚本直接把某输入变量作为Include的参数，造成任意引用脚本、绝对路径泄露等漏洞。看以下代码： <br /><br /><p class="code">... <br />$includepage=$_GET["includepage"]; <br />include($includepage); <br />...</p><br />很明显，我们只需要提交不同的Includepage变量就可以获得想要的页面。如果提交一个不存在的页面，就可以使PHP脚本发生错误而泄露实际绝对路径(这个问题的解决办法在下面的文章有说明)。 <br /><br />2.漏洞解决： <br /><br />这个漏洞的解决很简单，就是先判断页面是否存在再进行Include。或者更严格地，使用数组对可Include的文件作出规定。看以下代码： <br /><br /><p class="code">$pagelist=array("test1.php","test2.php","test3.php"); //这里规定可进行include的文件 <br />if(isset($_GET["includepage"])) //判断是否有$includepage <br />{ <br />$includepage=$_GET["includepage"]; <br />foreach($pagelist as $prepage) <br />{ <br />if($includepage==$prepage) //检查文件是否在允许列表中 <br />{ <br />include($prepage); <br />$checkfind=true; <br />break; <br />} <br />} <br />if($checkfind==true){ unset($checkfind); } <br />else{ die("无效引用页！"); } <br />}</p><br />这样就可以很好地解决问题了。 <br /><br />小提示：有此问题的函数还有：require()，require_once()，include_once()，readfile()等，在编写的时候也要注意。 <br /><br /><strong>未对输入变量进行过滤 </strong><br /><br />1.漏洞原因： <br /><br />这个漏洞早在ASP中出现过，当时造成的注入漏洞不计其数。但由于PHP在当时的影响力较小，所以没有太多的人能够注意这点。对于PHP来说，这个漏洞 的影响性比ASP更大，因为有比较多的PHP脚本使用到文本型数据库。当然也存在SQL语句的注入问题。举个比较经典的例子，首先是数据库的： <br /><br /><p class="code">$id=$_GET["id"]; <br /><br />$query="SELECT * FROM my_table where id='".$id."'"; //很经典的SQL注入漏洞 <br />$result=mysql_query($query);</p><br />这里很明显我们可以用注入来获得数据库的其它内容了。这里就不再详细叙述，和ASP注入一样的，大家可以看看以前的黑防。然后我们看文本数据库的问题： <br /><br /><p class="code">$text1=$_POST["text1"]; <br />$text2=$_POST["text2"]; <br />$text3=$_POST["text3"]; <br /><br />$fd=fopen("test.php","a"); <br />fwrite($fd,"\r\n$text1&amp;line;$text2&amp;line;$text3"); <br />fclose($fd);</p><br />文本的漏洞可以说是更加严重。倘若我们的提交的变量中插入一段很小的PHP代码，就可以另这个文本数据库test.php变成PHP后门。甚至插入上传代码，让我们可以上传一个完善的PHP后门。接着提升权限，服务器就是你的了。 <br /><br />2.漏洞解决： <br /><br />这个漏洞的解决方法其实很简单，就是严格对全部提交的变量进行过滤。对一些敏感的字符进行替换。我们可以借助PHP提供的htmlspecialchars()函数来替换HTML的内容。这里给出一段例子： <br /><br /><p class="code">//构造过滤函数 <br />function flt_tags($text) <br />{ <br />$badwords=array("操你妈","fuck"); //词汇过滤列表 <br />$text=rtrim($text); <br />foreach($badwords as $badword) //这里进行词汇的过滤 <br />{ <br />if(stristr($text,$badword)==true){ die("错误：你提交的内容含有敏感字眼，请不要提交敏感内容。"); } <br />} <br />$text=htmlspecialchars($text); //HTML替换 <br />//这两行把回车替换为 <br /><br />$text=str_replace("\r"," ",$text); <br />$text=str_replace("\n","",$text); <br />$text=str_replace("&amp;line;","│",$text); //文本数据库分隔符"&amp;line;"替换为全角的"│" <br />$text=preg_replace("/\s{ 2 }/"," ",$text); //空格替换 <font color="#ffffff">中国网管联盟</font><br />$text=preg_replace("/\t/"," ",$text); //还是空格替换 <br />if(get_magic_quotes_gpc()){ $text=stripslashes($text); } //如果magic_quotes开启，则进行\'的替换 <br />return $text; <br />} <br /><br />$text1=$_POST["text1"]; <br />$text2=$_POST["text2"]; <br />$text3=$_POST["text3"]; <br /><br />//过滤全部输入 <br />$text1=flt_tags($text1); <br />$text2=flt_tags($text2); <br />$text3=flt_tags($text3); <br /><br />$fd=fopen("test.php","a"); <br />fwrite($fd,"\r\n$text1&amp;line;$text2&amp;line;$text3"); <br />fclose($fd);</p><br />经过一番替换和过滤后，你就可以安全地把数据写入文本或数据库了。 <br /><br /><strong>管理员判断不完全</strong><br /><br />1.漏洞原因： <br /><br />我们用PHP写脚本，通常要涉及管理员的权限问题。而一些脚本仅仅对管理员权限作出"是"判断，而往往忽略了"否"判断。在PHP配置文件中 register_globals打开的情况下（4.2.0以后版本默认关闭，但有不少人为了方便而打开它，这是极度危险的行为），就会出现提交变量冒充 管理员的情况。我们看一下的例子代码： <br /><br /><p class="code">$cookiesign="admincookiesign"; //判断是否Admin的cookie变量 <br />$adminsign=$_COOKIE["sign"]; //获取用户的cookie变量 <br /><br />if($adminsign==$cookiesign) <br />{ <br />$admin=true; <br />} <br /><br />if($admin){ echo "现在是管理员状态。"; }</p><br />看上去好像很安全的样子，呵呵。现在我们假设PHP配置文件中register_globals为打开状态。我们提交这样一个地址“test.php? admin=true”，结果看到了吗？我们虽然没有正确的Cookie，但由于register_globals为打开状态，使得我们提交的admin 变量自动注册为true。而且脚本缺少“否”判断，就使得我们顺利地通过admin=true取得管理员的权限了。这个问题存在于大部分网站和论坛当中。 <br /><br />2.漏洞解决： <br /><br />解决这个问题，我们只需要在脚本中加入对管理员的“否”判断即可。我们仍然假设PHP配置文件中register_globals为打开状态。看一下的代码： <br /><br /><p class="code">$cookiesign="admincookiesign"; //判断是否Admin的cookie变量 <br />$adminsign=$_COOKIE["sign"]; //获取用户的cookie变量 <br /><br />if($adminsign==$cookiesign) <br />{ <br />$admin=true; <br />} <br />else <br />{ <br />$admin=false; <br />} <br />if($admin){ echo "现在是管理员状态。"; }</p><br />这样，就算攻击者在没有正确Cookie的情况下提交了admin=true的变量，脚本在以后的判断中也会把$admin设置为False。这样就解 决了部分的问题。但由于$admin是变量，倘若在以后的其他脚本引用中出现了漏洞使得$admin被重新赋值就会引发新的危机。因此，我们应该使用常量 来存放管理员权限的判定。使用Define()语句定义一个admin常量来记录管理员权限，在此以后若配重新赋值就会出错，达到保护的目的。看以下代 码： <br /><br /><p class="code">$cookiesign="admincookiesign"; //判断是否Admin的cookie变量 <br />$adminsign=$_COOKIE["sign"]; //获取用户的cookie变量 <br /><br />if($adminsign==$cookiesign) <br />{ <br />define(admin,true); <br />} <br />else <br />{ <br />define(admin,false); <br />} <br />if(admin){ echo "现在是管理员状态。"; }</p><br />值得注意的是，我们使用了Define语句，所以在调用Admin常量时前面不要习惯性的加变量符号$，而应该使用Admin和!admin。 <br /><br />文本数据库暴露 <br /><br />1.漏洞原因： <br /><br />前面已经说过，由于文本数据库具有很大的灵活性，不需要任何外部支持。加上PHP对文件的处理能力十分强，因此文本数据库在PHP脚本中的应用甚广。甚至有几个很好的论坛程序就是使用文本数据库的。但有得必有失，文本数据库的安全性也是比其他数据库要低的。 <br /><br />2.漏洞解决： <br /><br />文本数据库作为一个普通的文件，它可以被下载，就像MDB一样。所以我们要用保护MDB的办法来保护文本数据库。把文本数据库的后缀名改为.PHP。并 在数据库的第一行加入。这样文本数据库就会作为一个PHP文件，并且在第一行退出执行。也就是返回一个空页面，从而达到保护文本数据库的目的。 <br /><br /><strong>错误路径泄露 </strong><br /><br />1.漏洞原因： <br /><br />PHP遇到错误时，就会给出出错脚本的位置、行数和原因，例如： <br /><br /><p class="code">Notice: Use of undefined constant test - assumed 'test' in D:\interpub\bigfly\test.php on line 3</p><br />有很多人说，这并没有什么大不了。但泄露了实际路径的后果是不堪设想的，对于某些入侵者，这个信息可是非常重要，而事实上现在有很多的服务器都存在这个问题。 <br /><br />有些网管干脆把PHP配置文件中的display_errors设置为Off来解决，但本人认为这个方法过于消极。有些时候，我们的确需要PHP返回错误的信息以便调试。而且在出错时也可能需要给用户一个交待，甚至导航到另一页面。 <br /><br />2.漏洞解决： <br /><br />PHP从4.1.0开始提供了自定义错误处理句柄的功能函数set_error_handler()，但很少数脚本编写者知道。在众多的PHP论坛中，我只看见很少一部分对此情况进行了处理。set_error_handler的使用方法如下： <br /><br /><p class="code">string set_error_handler ( callback error_handler [, int error_types])</p><br />现在我们就用自定义的错误处理把实际路径过滤掉。 <br /><br /><p class="code">//admin为管理员的身份判定，true为管理员。 <br />//自定义的错误处理函数一定要有这４个输入变量$errno,$errstr,$errfile,$errline，否则无效。 <br />function my_error_handler($errno,$errstr,$errfile,$errline) <br />{ <br />//如果不是管理员就过滤实际路径 <br />if(!admin) <br />{ <br />$errfile=str_replace(getcwd(),"",$errfile); <br />$errstr=str_replace(getcwd(),"",$errstr); <br />} <br /><br />switch($errno) <br />{ <br />case E_ERROR: <br />echo "ERROR: [ID $errno] $errstr (Line: $errline of $errfile) <br />\n"; <br />echo "程序已经停止运行，请联系管理员。"; <br />//遇到Error级错误时退出脚本 <br />exit; <br />break; <br />case E_WARNING: <br />echo "WARNING: [ID $errno] $errstr (Line: $errline of $errfile) <br />\n"; <br />break; <br />default: <br />//不显示Notice级的错误 <br />break; <br />} <br />} <br /><br />//把错误处理设置为my_error_handler函数 <br />set_error_handler("my_error_handler"); <br />…</p><br />这样，就可以很好地解决安全和调试方便的矛盾了。而且你还可以花点心思，使错误提示更加美观以配合网站的风格。不过注意两点是： <br /><br />（1）E_ERROR、E_PARSE、E_CORE_ERROR、E_CORE_WARNING、E_COMPILE_ERROR、 E_COMPILE_WARNING是不会被这个句柄处理的，也就是会用最原始的方式显示出来。不过出现这些错误都是编译或PHP内核出错，在通常情况下 不会发生。 <br /><br />（2）使用set_error_handler()后，error_reporting ()将会失效。也就是所有的错误（除上述的错误）都会交给自定义的函数处理。 <br />其它有关于set_error_handler()的信息，大家可以参考PHP的官方手册。 <br /><br /><strong>POST漏洞</strong><br /><br />1.漏洞原因： <br /><br />前面已经说过，依靠register_globals来注册变量是个不好的习惯。在一些留言本和论坛程序中，更要严格检查获得页面的方式和提交的时间间隔。以防止灌水式发帖和外部提交。我们看一下以下某留言本程序的代码： <br /><br /><p class="code">... <br />$text1=flt_tags($text1); <br />$text2=flt_tags($text2); <br />$text3=flt_tags($text3); <br /><br />$fd=fopen("data.php","a"); <br />fwrite($fd,"\r\n$text1&amp;line;$text2&amp;line;$text3"); <br />fclose($fd);</p><p class="Wns400"></p>很明显的，如果我们提交网址”post.php?text1=testhaha&amp;text2=testhaha&amp;text3= testhaha”。数据就会被正常写入文件中。此程序并没有检测变量的来源和浏览器获得页面的方式。如果我们向这个页面重复多次提交，就会起到洪水的作 用。现在也有一些软件利用这个漏洞来在论坛或留言本上发广告，这是可耻的行为（我朋友的留言本就在1星期内被灌了10多页，无奈）。 <br /><br />2.漏洞解决： <br /><br />在进行数据处理和保存前，首先判断浏览器的获得页面方式。使用$_SERVER["REQUEST_METHOD"]变量来获得浏览器的获得页面方式。 检查其是否为”POST”。在脚本中使用session来记录用户是否通过正常途径（即填写提交内容的页面）来提交数据。或使用$_SERVER ["HTTP_REFERER"]来检测，但不推荐这样做。因为部分浏览器没有设置REFERER，有部分防火墙也会屏蔽REFERER。另外，我们也要 对提交内容检查，看数据库中是否有重复内容。以留言本为例，使用Session进行判定： <br />填写浏览内容的页面中，我们在最前端加上： <br /><br /><p class="code">$_SESSION["allowgbookpost"]=time(); //登记填写时的时间</p><br />在接受留言数据并保存的页面中我们在进行数据处理前我们也用Session进行以下处理： <br /><br />if(strtoupper($_SERVER["REQUEST_METHOD"])!=”POST”){ die("错误：请勿在外部提交。"); } //检查页面获得方法是否为POST <br />if(!isset($_SESSION["allowgbookpost"]) or (time()-$_SESSION["allowgbookpost"] &lt; 10)){ die("错误：请勿在外部提交。"); } //检查留言填写时的时间 <br />if(isset($_SESSION["gbookposttime"]) and (time()-$_SESSION["gbookposttime"] &lt; 120)){ die("错误：两次提交留言的间隔不得少于 2 分钟。"); } //检查留言间隔 <br /><br />unset($_SESSION["allowgbookpost"]); //注销allowgbookpost变量以防止一次进入填写页面多次进行提交 <br />$_SESSION["gbookposttime"]=time(); //登记发送留言的时间，防止灌水或恶意攻击 <br />... <br />数据处理及保存 <br /><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6857.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-08-20 08:52 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/08/20/6857.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UTF8下中文命名文件下载问题</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/08/13/6838.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Thu, 13 Aug 2009 08:13:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/08/13/6838.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6838.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/08/13/6838.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6838.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6838.html</trackback:ping><description><![CDATA[友情链接：<a title="天津打折促销购物" href="http://www.tjcuxiao.com" target="_blank">http://www.tjcuxiao.com</a> 和<a title="目击者 肇事 行凶 腐败 贪污" href="http://www.mujiz.cn" target="_blank">http://www.mujiz.cn</a>】<br />如果$filename是UTF-8编码的，有些浏览器就无法正常处理了。比如把上面那个程序稍稍改一下：<pre>&lt;?php
$filename = "中文 文件名.txt";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $filename);

print "Hello!";
?&gt;</pre><p>把程序保存成UTF-8编码再访问，IE6下载的文件名就会乱码。 FF3下下载的文件名就只有“中文”两个字。Opera 9下一切正常。</p><span begin="" pukiwiki="" generated="" code--=""><p>输出的header实际上是这样子：</p><pre>Content-Disposition: attachment; filename=中文 文件名.txt</pre><p>其实按照<a href="http://tools.ietf.org/html/rfc2231"><font color="#448608">RFC2231</font></a>的定义，多语言编码的Content-Disposition应该这么定义：</p><pre>Content-Disposition: attachment; filename*="utf8''%E4%B8%AD%E6%96%87%20%E6%96%87%E4%BB%B6%E5%90%8D.txt"</pre><p>即：</p><ul style="PADDING-LEFT: 16px; MARGIN-LEFT: 16px"><li>filename后面的等号之前要加 * 
</li><li>filename的值用单引号分成三段，分别是字符集(utf8)、语言(空)和urlencode过的文件名。 
</li><li>最好加上双引号，否则文件名中空格后面的部分在Firefox中显示不出来 
</li><li>注意urlencode的结果与php的urlencode函数结果不太相同，php的urlencode会把空格替换成+，而这里需要替换成%20</li></ul><p>经过试验，发现几种主流浏览器的支持情况如下：</p><div><table cellspacing="1" border="0"><tbody><tr><td></td><td filename="&lt;URL编码之后的UTF-8文件名&gt;"></td></tr><tr><td rowspan="2">FF3</td><td filename="UTF-8文件名"></td></tr><tr><td filename*="utf8''&lt;URL编码之后的UTF-8文件名&gt;"></td></tr><tr><td></td><td filename="UTF-8文件名"></td></tr><tr><td></td><td><p>这样看来，程序必须得这样写才能支持所有主流浏览器：</p><pre>&lt;?php

$ua = $_SERVER["HTTP_USER_AGENT"];

$filename = "中文 文件名.txt";
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);

header('Content-Type: application/octet-stream');

if (preg_match("/MSIE/", $ua)) {
 header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');
} else if (preg_match("/Firefox/", $ua)) {
 header('Content-Disposition: attachment; filename*="utf8\'\'' . $filename . '"');
} else {
 header('Content-Disposition: attachment; filename="' . $filename . '"');
}

print 'ABC';
?&gt;
</pre></td></tr></tbody></table></div></span><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6838.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-08-13 16:13 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/08/13/6838.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>百度和Google收录规律</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6833.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Wed, 12 Aug 2009 01:34:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6833.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6833.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6833.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6833.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6833.html</trackback:ping><description><![CDATA[<div>【友情链接：<a title="天津打折促销购物" href="http://www.tjcuxiao.com" target="_blank">http://www.tjcuxiao.com</a> 和<a title="目击者 肇事 行凶 腐败 贪污" href="http://www.mujiz.cn" target="_blank">http://www.mujiz.cn</a>】<a href="http://hplc2.blog.163.com/blog/static/52546820091210235231/" target="_blank"><br />百度Google收录规律</a></div>
		<div> </div>
		<div>摘要：对于网站的更新和收录，搜索引擎都有它们各自的规律。因此每一次网站的更新收录，都牵动着每一个网站运营者的神经。因为更新收录是百度排名和Google排名的基础，当然每一个网站的自身情况不一样，更新收录也不能一概而论的。根据互联网实战专家黄相如的细心观察与对照，总结出百度、 Google的更新收录规律与现象。现中国B2B研究中心将研究成果披露如下：<br /><br />1、百度更新及收录是根据你网站的质量和更新速度的变化而变化的，你快它也快，你慢它也慢；而Google更新则比较“稳重”，基本上是一周一更新，对于企业网站来说。如果是大门户网上，可能Google更新和收录的情况会不一样。许多网站运营者在进行百度优化和Google优化的时候，就会经常想着，到底是百度更新更快还是Google更新更快？而我觉得这不是一个绝对数。<br /><br />2、百度对原创文章的重视程度比Google更加重视，对于一个完全相同内容的网站，在Google已经收录了上千个网页，而百度则还site不到信息。百度对收录质量也在不断提高，早几年以前都说百度收录的数量很浮夸，而现在，很多大网站的收录数量被砍一半，甚至远远低于Google的收录数量。这一举动也说明百度在改变收录标准和更新标准。<br /><br />3、令百度优化者经常头疼的事就是自己的网站经常被百度 “k”，轻则K过首页，重则K掉其它更多的页面，甚至一毛不留。这是百度对于百度优化作弊者的一种惩罚机制。而且会有一种连带责任。如果某个网站被k，而你的网站有指向它的友情链接，那么你的网站也会被“K”。而且不会事先通知你。出现被“K”是很痛苦的事，如果你不采取补救措施，那么就可能一直“K”之下去。最后你的网站会被踢出百度之门。 
<div><div>一、百度搜索引擎的特点<br /><br />1.基于字词结合的信息处理方式。巧妙解决了中文信息的理解问题，极大地提高了搜索的准确性和查全率。<br /><br />2.支持主流的中文编码标准。包括GBK（汉字内码扩展规范）、GB2312（简体）、BIG5（繁体），并且能够在不同的编码之间转换。<br /><br />3.智能相关度算法。采用了基于内容和基于超链分析相结合的方法进行相关度评价，能够客观分析网页所包含的信息，从而最大限度保证了检索结果相关性。<br /><br />4.检索结果能标示丰富的网页属性（如标题、网址、时间、大小、编码、摘要等），并突出用户的查询串，便于用户判断是否阅读原文。<br /><br />5.百度搜索支持二次检索（又称渐进检索或逼进检索）。可在上次检索结果中继续检索，逐步缩小查找范围，直至达到最小、最准确的结果集。利于用户更加方便地在海量信息中找到自己真正感兴趣的内容。<br /><br />6.相关检索词智能推荐技术。在用户第一次检索后，会提示相关的检索词，帮助用户查找更相关的结果，统计表明可以促进检索量提升10-20%.<br /><br />7.运用多线程技术、高效的搜索算法、稳定的UNIX平台、和本地化的服务器，保证了最快的响应速度。百度搜索引擎在中国境内提供搜索服务，可大大缩短检索的响应时间（一个检索的平均响应时间小于0.5秒）<br /><br />8.可以提供一周、二周、四周等多种服务方式。可以在7天之内完成网页的更新，是目前更新时间最快、数据量最大的中文搜索引擎。<br /><br />9.检索结果输出支持内容类聚、网站类聚、内容类聚+网站类聚等多种方式。支持用户选择时间范围，提高用户检索效率。<br /><br />10.智能性、可扩展的搜索技术保证最快最多的收集互联网信息。拥有目前世界上最大的中文信息库，为用户提供最准确、最广泛、最具时效性的信息提供了坚实基础。<br /><br />11.分布式结构、精心设计的优化算法、容错设计保证系统在大访问量下的高可用性、高扩展性、高性能和高稳定性。<br /><br />12.高可配置性使得搜索服务能够满足不同用户的需求。<br /><br />13.先进的网页动态摘要显示技术。<br /><br />14.独有百度快照。<br /><br />15.支持多种高级检索语法，使用户查询效率更高、结果更准。已支持“+”（AND）、“-”（NOT）、“｜”（OR）、“site：”、“link：”，还将继续增加其它高效的搜索语法。</div><div><div>二、如何面对搜索引擎降权？<br /><br />被Baidu进行降权，甚至被封杀。这些问题是许许多多网站都曾遇见到过的，有些网站并没有进行恶意作弊，优化也是很正常的，是什么原因造成的这些问题？资深的互联网实战专家黄相如对baidu的这一现象进行了深入地研究和分析认为：站在SEO的角度去想，主要是网站的自身原因。一个网站可能会因为结构的不合理性就会容易出现类似的问题。那么如何提升你的站点对搜索引擎的权重？或者是如何解决降权或封站问题呢？今天笔者黄相如将通过这篇文章与大家讨论研究。<br /><br />面对降权要冷静分析，主要问题还是在与网站本身。所以要从网站开始，如果站点已经被降权了我们该怎么办？</div><div><div>一般降权分为四种：<br /><br />1、站点部份收录内容减少；<br /><br />2、网站首页被屏蔽；<br /><br />3、网站外部链接减少；<br /><br />4、网站全部页面删除。<br /><br />站点收录内容减少，面对此问题，首先应该考虑网的内部链接是否存在过失，是不是网站内出现过多死链。网站首页被屏蔽，这类问题主要出现在BAIDU.这个问题解决比较简单，直接将服务器的主机头索引修改为其他页面。或将首页的文件名称重新修改。但是做这些的先决条件是这个页面没有进行过度优化。网站外部链接减少，主要是因为你站点的外部连接质量不高，搜索引擎再进行调整的时候将你的外部那些“垃圾”链接删除。所以一定要注重高质量外部资源。网站全部页面删除，这个问题是比较严重，一般出现了这个问题就意味着你的站点肯定存在很大问题。有可能是过度优化、有可能是网站结构等等。遇到这样的问题必须要将站点恢复原样，去掉多余链接修改网站框架结构。等待搜索引擎重新收录，一般这个周期会很长。如果这个站点域名不是很重要的话，可以考虑换掉域名，重新提交搜索引擎。<br /><br />对于出现搜索引擎对网站降权（搜索引擎封闭站点的某个页面，或减少收录量，这就是我们经常说的降权）或封站（搜索引擎不收录该站点，或者将该站点在搜索引擎中的所有页面删除）问题，主baidu只收录网站的首页。而GOOGLE收录效果却良好。解决这些问题根本上就是要先提升站点在搜索引擎中的权重，让搜索引擎认可您的站点。黄相如在多年的实战研究中，总结了以下问题：</div><br /><div>1.精代码：很多网站都为了自己页面的美观华丽，为了实现一些复杂的功能而使用很多繁琐的程序来进行控制，而且在部署使用这些程序的时候，非常不注意这些程序的工整性，经常没有任何原则的随便胡乱插入，这样会让搜索引擎非常困惑，没有思路。所以为了搜索引擎能够更好的收录您的站点，请放弃那些花哨或一些不实用的功能吧。<br /><br />2.改结构：网站的结构也就是说网站的整体框架。有些网站，为了实现一些在线功能，一个页面出现了多个 iframe.虽然搜索引擎都在进步，Google已经避免了此问题，但Baidu仍然不是很喜欢存在iframe的页面。对于网站的内部链接情况，一定要本着清楚明白、保持链接通畅、尽量不要出现死链坏链情况。对于出现死链问题（如果是自己的服务器），可以重新制定错误信息。定期使用 GoogleWebmasterTools或Xenu来检查自己的站点。<br /><br />说到网站的整体结构，有过SEO经验或营销型网站（从用户体验，到用户行为跟踪，再到最后销售为一体的网站）建设的人都知道，网站漂亮不是目的，目的是将网站的访问用户转换，让网站高效率被搜索引擎认可。而要做到这些，网站的结构是非常重要的。说的简单一些，网站结构就是让用户看到他想看的东西，让他能时刻找到想要的信息和产品，并随时找到你的联系方式。搜索引擎方面，让搜索引擎能够顺利通过页面的链接抓取到网站中的每个页面，具体方面如建立有效的链接导航，让每个页面都具备导航功能，能方便引擎，也能方便用户。建立网站地图，将重要的内容或目录在地图中体现。尽量使用HTML页面。<br /><br />3.重质量：网站应当具有一定的质量，如果一个网站不能给用户提供有价值的信息和内容，会被搜索引擎大打折扣，搜索引擎也一样很注重网站内容、页面质量，内部链接、外部链接质量和网站最终页面质量。黄相如认为网站的优质内容在优化中占据很大比重！既然内容很重要，应该怎样去创造优质内容呢？搜索引擎读取文章只能把网页中的内容分离，分别建立索引，然后通过分词等技术对内容进行机器编译。再后是用户使用引擎搜索相关关键词，搜索引擎提供内容。按照它对页面网站的权重、唯一性等将网站或相关页面提前或靠后，展示给用户。所以对于优质内容来说尽量使用原创内容。每个人的写作方式都是不同的，所体现出来的断词形式，也肯定不同，所以尽量保证内容的原创唯一性。页面质量，指的是最终的终端页面质量，内容也算其一了。黄相如还要指出一些网站不曾注意的但是很重要的方面。很多网站都有自己的新闻页面，这个页面可以说是终端页面了，但是站长都会忘记增加此类页面的关键词和一些最基本的meta标记，具体标记就不说了，真的应该注意一下。但切记不要滥用。Baidu的贴吧、知道、词条，可以说是Baidu的几大产品中最有意义的，这几个产品创造了很多唯一独立内容，而且很多内容都是按照中国人的搜索习惯研制的。也可以说这几个产品为各大搜索引擎都提供了比较好的内容。<br /><br />搜索引擎的进步体现在不断的为用户提供更高质量内容，并且会更注重网站的时效性，搜索引擎会把最新的新闻相关内容提高到搜索引擎搜索结果前面，尤其是新闻搜索。这块做好之后，也可以给你的站点带来一些流量，一些客户。如何来优化网站实效性呢？如何让搜索引擎更快收录到我的新闻终端页面呢？首先要保证的是网站在搜索引擎中的权重，你的站点与搜索引擎必须要有个良好的“合作”关系。让Spider们及时去关注自己的网站，甚至驻留Spider，这你就成功了！主要通过高质量外部资源来托起你的站点。网站页面本身应该注意代码简单，加入应有标记，保持良好链接。还有一点非常重要，那就是新闻页面的名称或目录。页面文件名来尽量使用NEWS071109.HTML或071109.HTML这样的名字，因为这些具有时间代表的文件名称是搜索引擎判断新闻的一个重要条件。对于专题来说搜索引擎也非常喜欢，因为他存在唯一性和时效性，对于目录性的专题来说，搜索引擎也比较喜欢。对于内容，该使用H1的地方一定要使用，并且重点词进行加粗等等。<br /><br />4.轻优化：你在做网站的时候，只要告诉你的设计人员SEO的几个大的原则（网络上有很多介绍SEO的文章，我在这里就不多说了），让他按照这几大原则去做就可以了。千万不要为了优化而优化，这样效果可能适得其反。也不要累积关键词，为了扩大自己外链而疯狂的增加链接。我有很多客户的网站都因此而付出了很大的代价，换来的是搜索引擎对网站的降权，才去找原因。<br /><br />5. 增外链：一个网站有了完美的结构，具备营销而让搜索引擎高度认可的条件后，这就够了吗？黄相如认为这是远远不够的。搜索引擎认可了，如果还要让它高度认可，这就需要外部链接了。外部链接也要注重质量。一个新站点，就不要在乎你的外部链接是否是高质量了。你只要找一些结构合理，不存在欺骗性，不存在过度优化的站点去交换链接好了。因为这些站点都是具备一定潜力的站点，有可能将来就会成为一个高权重的站点。如果网站已经拥有了一些搜索引擎方面的权重，那么在选择外部链接的时候就应该注意一下了，绝对不能与被降权的站点进行链接交换和链接。还有一点，就是不要吝啬你的链接，适当去为一些低权重，高质量的网站进行链接。处处留心，当你看到可以发布自己网站链接的地方一定要发布。但千万不要在那些贴满链接的留言本、论坛等地方发布。还有就是多多加入目录，现在国内有很多非常好的中文目录，如果能加入国外的目录引擎也可以。</div></div></div></div></div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6833.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-08-12 09:34 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6833.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>百度及Google收录网站的一些特征</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6832.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Wed, 12 Aug 2009 01:31:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6832.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6832.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6832.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6832.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6832.html</trackback:ping><description><![CDATA[<p>
				<font face="Verdana">【友情链接：<a title="天津打折促销购物" href="http://www.tjcuxiao.com" target="_blank">http://www.tjcuxiao.com</a> 和<a title="目击者 肇事 行凶 腐败 贪污" href="http://www.mujiz.cn" target="_blank">http://www.mujiz.cn</a>】<br /><br />Google收录有以下特点：</font>
		</p>
		<p>
				<font face="Verdana">　　首先，Google对新站或较新鲜度的东西都比较敏感，有很高的查知性。它会通过外部链接很快查看到你的站点，通常通过外部链接的收录率多少，给予一个站的评价高低，如果发现新站点击或收录率高那么自然收录速度也很快。</font>
		</p>
		<p>
				<font face="Verdana">　　另外，Google 使用 PageRank 技术检查整个网络链接结构，并确定哪些网页重要性最高。然后进行超文本匹配分析，以确定哪些网页与正在执行的特定搜索相关。在综合考虑整体重要性以及与特定查询的相关性之后，Google 才将最相关最可靠的搜索结果放在首位。这也是Google收录网页的特点之一。</font>
		</p>
		<p>
				<font face="Verdana">　　特点二，Google会将链接的文字描述作为关键词加以索引，所以我们在作友情链接时千万要仔细设计链接的文字描述，使之既符合网站的定位又不失相关性，以此博得Google的信任。</font>
		</p>
		<p>
				<font face="Verdana">　　特点三，Google 漫游器会定期抓取 Web，将大量网页列入索引。稍后完成的下一次抓取会注意到新网站、对现有网站的更改以及失效的链接，并对内容的变化在搜索结果中加以调整。</font>
		</p>
		<p>
				<font face="Verdana">　　那么，百度搜索引擎收录习惯，它较重视第一次收录印象，根据第一次印象做为网站重要与非重要衡量指标。相对Google而言，百度搜索引擎的人为参与度较高，也就是说在某些层面上可能由人来决定是否收录网页而不是由机器来决定。所以，网站在登录百度搜索引擎之前最好把内容做得丰富点、原创内容多一点、网页关键词与内容的相关度高一点，这样才能给百度较好的初次印象。</font>
		</p>
		<p>
				<font face="Verdana">　　百度对网页的更新相对Google而言更加敏感，可能这与百度的本土性格有关。百度搜索引擎每周更新，网页视重要性有不同的更新率，频率在几天至一月之间。所以在百度的搜索结果中基本上都标明了收录时间。</font>
		</p>
		<p>
				<font face="Verdana">　　看了以上针对百度与Google的收录习惯，以后大家在优化过程中会更有针对性，在内容方面尽可多些原创，有时候原创会比你刻意增加关键词更有收录效果。</font>
		</p>
		<p>
				<font face="Verdana">　　大家一定要注意，虽然关键字密度是排名的一个重要的因素，当然不可忽略，但最重要的还是内容。很多人都为了达到2%~8%的关键字密度而不故内容质量，刻意地在页面加上所优化的目标关键了，其实这样做有时候反而会得到相反的效果</font>
		</p><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6832.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-08-12 09:31 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6832.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>baidu和Google搜索引擎收录网站之比较</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6831.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Wed, 12 Aug 2009 01:28:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6831.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6831.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6831.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6831.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6831.html</trackback:ping><description><![CDATA[【友情链接：<a title="天津打折促销购物" href="http://www.tjcuxiao.com" target="_blank">http://www.tjcuxiao.com</a> 和<a title="目击者 肇事 行凶 腐败 贪污" href="http://www.mujiz.cn" target="_blank">http://www.mujiz.cn</a>】<br />根据搜索引擎当前的发展情况比较和分析一下百度和Google这两大搜索引擎在收录网站方面的区别。 <br /><br />　　<b>首页规则</b><br /><br />　　搜索引擎的索引更新速度是衡量搜索质量的一个重要的参数，对于大型网站（比如门户新闻网站）以及其他更新量大的网站，百度和Google的索引速度都很快，基本上都能做到当天更新。 <br /><br />　　但是对于更新量小的网站，例如博客，两者就有较大区别，Google对于高权重并提交Sitemaps和Ping的网站，索引速度可以达到分钟级别，有时刚刚写完一篇文章，几分钟后，就能在Google中搜索到解决，但是对于百度来说，索引速度较慢，通常仅仅更新了博客网站的首页，搜索文章标题，排在前面的是博客首页或者目录页，而不是文章页。 <br /><br />　　总的来说，百度对于网站首页的关注以及权重给的似乎特别高，而Google对于最终的文章内容页面的关注多于百度。 <br /><br />　　<b>半个月规则</b><br /><br />　　百度对于更新量较小的博客，收录页面有一个奇怪的时间规则限制：半个月规则，根据我对于月光博客文章收录速度的观察，通常情况下，半个月之内发布的文章，使用百度搜索文章标题，排在前面的基本上都是<a class="article" href="http://www.enet.com.cn/enews/" target="_blank">门户网站</a>转载或聚合我的文章，我写的原始文章不见踪影。而使用Google搜索，我的原文基本上都是第一位。 <br /><br />　　而大约半个月之后，我的文章的原始内容才在百度上出现，这时候搜索文章的标题，我的原文才会成为百度搜索结果的第一位。 <br /><br />　　<b>权重计算规则</b><br /><br />　　Google计算权重的方式主要参考页面的反向链接，如果别人转载我的文章并添加了原文链接，那么Google通常会给予原始文章较高的权值，而百度似乎对于自己的网站（百度知道、百度空间、百度百科等）给予较高的权值，并且对于更新频繁的大型门户网站更为青睐，而对于反向链接似乎没有给予太多的权重。 <br /><br />　　<b>新站规则</b><br /><br />　　一个新注册的网站，经过一些宣传之后，通常Google就会对其进行收录，但赋予的权值并不太高。 <br /><br />　　百度对于新站不会立刻收录，并且相当长的时间内都不会收录，当新网站在搜索引擎有了一个不错的表现，并且有了较多的反向链接，会出现一个阀值，百度判断其网站内容不属于明显复制其他网站内容之后，会开始收录这个新站点内容，这时候网站才会出现来自百度的流量。 <br /><br />　　总的来说，在网站收录速度上来看，Google现在比百度要快，不过由于百度的用户更多一些，所以网站搜索来源大多还是来自百度的多一些。不过对于技术博客来说，来源Google的访问量应该和百度旗鼓相当了。 <br /><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6831.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-08-12 09:28 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/08/12/6831.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql proxy 实现读写分离</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/08/07/6825.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Fri, 07 Aug 2009 03:15:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/08/07/6825.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6825.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/08/07/6825.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6825.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6825.html</trackback:ping><description><![CDATA[<p>【<a title="天津促销网" href="http://www.tjcuxiao.com" target="_blank">http://www.tjcuxiao.com</a>和<a title="目击者" href="http://www.mujiz.cn" target="_blank">http://www.mujiz.cn</a>友情赞助】<br /><br />听说<a href="http://jan.kneschke.de/2009/4/4/mysql-proxy-0-7-0-pre-release" target="_blank">mysql proxy 0.7.0即将发布</a>，正好<a href="http://www.ooso.net/archives/495" target="_blank">前些日子从bzr上获取mysql proxy的代码编译过</a>，看看当时bzr的版本号，和现在也差不了多少。在这期间，我又花了一些时间把mysql配置成读写分离，出了不少状况，由于使用的人不太多，解决问题超费劲——搜索不到有帮助的内容啊。</p>
		<p>但是我可能是比较幸运的，最后成功的实现了读写分离，目前在开发环境运行的比较稳定，所以有必要做个笔记分享一下。</p>
		<h2>读写分离脚本的问题</h2>
		<p>刚启动mysql proxy的时候，经常报错 -- "Mysql server has gone away"。我进一步缩小了可能出问题的范围(把环境简化是很重要的查错手段)，比如只连接一个mysql，或者只连接本机的mysql，没有太大帮助，最后是在mysql proxy的日志文件中看到些蛛丝马迹：</p>
		<blockquote>
				<p>(critical) proxy-plugin.c:1367: (connect_server) [string "/usr/local/share/mysql-proxy/r..."]:69: .address is deprecated. Use .src.name or .dst.name instead<br />(critical) (read_query) [string "/usr/local/share/mysql-proxy/r..."]:179: .address is deprecated. Use .src.name or .dst.name instead<br />(critical) proxy-plugin.c.1115: I have no server backend, closing connection </p>
		</blockquote>
		<p>在<a href="http://forums.mysql.com/list.php?146" target="_blank">mysql proxy的论坛</a>上看到有人碰到类似的问题，很简单，读写分离的lua脚本还是旧的，0.6.1时代的产物了，更糟糕的是，即便是即将发布的0.7.0，rw-splitting.lua也是旧版本的。lua脚本中的<b>.address</b>需要替换成<b>.src.name</b>或者<b>.dst.name</b>。</p>
		<p>
				<b>解决办法</b> —— 下载<a href="http://bazaar.launchpad.net/%7Ediego-fmpwizard/mysql-proxy/bug-43424/download/head%3A/rwsplitting.lua-20090112150705-l9v35osiopsn0nz0-10/rw-splitting.lua" target="_blank">更新之后的rw-splitting.lua</a>，情况会好转。</p>
		<h2>使用prepare方法无法获得结果</h2>
		<p>我在测试代码中采用php的pdo_mysql，单独连接mysql是毫无问题的，然而配合mysql proxy使用则是屡屡受挫，查询经常没有结果返回，比较随机，从日志中也找不到有帮助的内容。这次没有找到解决办法，所以我绕了过去，在连接mysql 的时候使用伪prepare的方式：</p>
		<div>
				<span>
						<a href="http://www.ooso.net/#" target="_blank">
								<br />
						</a>
				</span>
		</div>
		<div>
				<span>PHP:</span>
				<div>
						<div>
								<ol>
										<li style="FONT-WEIGHT: normal; COLOR: rgb(58,106,139); FONT-STYLE: normal; FONT-FAMILY: 'Courier New',Courier,monospace">
												<div style="FONT-WEIGHT: normal; FONT-FAMILY: 'Courier New',Courier,monospace">
														<span style="COLOR: rgb(0,0,255)">$option</span> = <span style="COLOR: rgb(0,0,102)">array</span><span style="FONT-WEIGHT: bold; COLOR: rgb(0,102,0)">(</span>PDO::<span style="COLOR: rgb(0,102,0)">ATTR_EMULATE_PREPARES</span> =&gt; <span style="COLOR: rgb(128,0,0)">1</span><span style="FONT-WEIGHT: bold; COLOR: rgb(0,102,0)">)</span>; </div>
										</li>
								</ol>
						</div>
				</div>
		</div>
		<p>据称emulate方式的性能比prepare要好，所以这也算安慰奖了。</p>
		<h2>专门的lua脚本分支</h2>
		<p>lua脚本开发滞后，是一个比较严重的问题，所以在邮件组上看到有个新的lua脚本分支出来 —— <a href="https://launchpad.net/mysql-proxy-lua-scripts" target="_blank">https://launchpad.net/mysql-proxy-lua-scripts</a>。希望开发速度能跟上来。</p>
		<p>
				<br />
		</p>
		<h2>keepalive参数</h2>
		<p>mysql proxy还不算太稳定，偶尔crash我也不觉得惊讶，所以新增的keepalive参数很有用。在proxy启动的时候，加上--keepalive参数，它便会努力保持proxy的运行状态，停止了也会自动重启。</p><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6825.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-08-07 11:15 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/08/07/6825.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Google Analytics 自定义应用---豆瓣案例</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/08/07/6824.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Fri, 07 Aug 2009 03:05:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/08/07/6824.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6824.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/08/07/6824.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6824.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6824.html</trackback:ping><description><![CDATA[<p>【<a href="http://www.tjcuxiao.com">www.tjcuxiao.com</a>和<a href="http://www.mujiz.cn">www.mujiz.cn</a>友情赞助】</p>
		<p>豆瓣从今年开始也加入 Google Analytics 的统计阵营。让我们通过它加载的 Google Analytics 源码，简单分析一下它都是怎么应用的。</p>
		<p>我们先从豆瓣的源码来看看它的Google Analytics统计代码</p>
		<p style="TEXT-ALIGN: center">
				<img alt="豆瓣 Google Analytics 代码" src="http://www.phpv.net/uploadfile/month_200907/local_SgQWoe9Mkc.jpg" />
				<br />豆瓣 Google Analytics 代码 </p>
		<p>我们知道一般默认的 Google Analytics代码如下：</p>
		<p style="TEXT-ALIGN: center">
				<img alt="默认  Google Analytics 统计代码" src="http://www.phpv.net/uploadfile/month_200907/local_TDkdtTlLOz.jpg" />
				<br />默认 Google Analytics 统计代码 </p>
		<p>两相对比，我们就会发现豆瓣加载 <code>ga.js </code>的方式与默认的方式有些不太一样，由于豆瓣并没有采用 https 加密访问，所以撇弃了默认的ga.js加载方式。</p>
		<p>默认的统计函数，<code>pageTracker </code>也被豆瓣改成了 <code>_ga</code> ，这个只是名称定义上的区别，并没有什么实质的改变。豆瓣的主要应用是下面两个函数：</p>
		<h3>使用 _ga._addOrganic 识别非主流搜索引擎</h3>
		<p>再来看豆瓣比默认 Google Analytics 代码增加的部分，那就是多了数个 <code>_ga._addOrganic </code>，这是 Google Analytics 添加自定义搜索引擎的代码。尽管 Google Analytics 对于主流的搜索引擎都能自动识别，但毕竟能识别的是国外的主流搜索引擎，在国内，像搜狐的 Sogou，QQ 的 soso，网易的有道等搜索引擎，<strong>都不能被 Google Analytics 正确识别，而被当作推荐来源</strong>。这时候我们就可以利用<code>_addOrganic</code> 参数来识别这些非主流搜索引擎，如豆瓣的做法。</p>
		<h3>使用 _addIgnoredOrganic 忽略关键字</h3>
		<p>除了添加自定义搜索引擎，豆瓣在最后还添加了如下这些代码:</p>
		<pre>_ga._addIgnoredOrganic("豆瓣");<br />_ga._addIgnoredOrganic("douban");<br />_ga._addIgnoredOrganic("豆瓣网");<br />_ga._addIgnoredOrganic("www.douban.com");<br /></pre>
		<p>这些代码用来把引号中的关键词从搜索引擎的关键词报告中排除，而当成直接点击量来源。</p>
		<p>为什么要这么做？因为一个知名的大网站，来自这些品牌词的搜索流量都非常大，常常是排在前几位的搜索关键词来源，而这通常是因为搜索引擎养成现在的人都懒得记网址，直接搜索品牌名来记住域名。这些品牌词对于网站的关键词来源分析并没有很直接的帮助，所以在来自品牌词的流量很大的情况下，可以直接把这些关键词识别成直接点击量来源。</p>
		<p>关于<strong>自定义 Google Analytics 搜索引擎</strong>和<strong>排除特定关键词为直接点击量来源</strong>的语法，可以参考<a title="_addOrganic() 与 _addIgnoredOrganic() 用法介绍" href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiSearchEngines.html" target="_blank"> Google Code 上关于这方面的详细介绍。</a></p>
		<h2>通过 _setVar 识别用户</h2>
		<p>当我们登录豆瓣后，再来分析豆瓣的源码，会发现多了一个<code>ga._setVar(”xxxx”)</code>的 Google Analytics 参数。</p>
		<p style="TEXT-ALIGN: center">
				<img alt="豆瓣使用 Google Analytics 的._setVar参数来跟踪登录用户行为" src="http://www.phpv.net/uploadfile/month_200907/local_pFIluyVQXs.jpg" />
				<br />豆瓣使用 Google Analytics 的._setVar参数来跟踪登录用户行为 </p>
		<p>
				<code>_setVar()</code> 函数是 Google Analytics 的用户定义函数，主要用于对特定来源的用户行为进行分类，例如可以对登录浏览的用户设置一个数值，然后在 Google Analytics 后台的<strong>访问者/用户定义</strong> 中查看其浏览属性。</p>
		<p style="TEXT-ALIGN: center">
				<img alt="Google Analytics 访问者/用户定义报告" src="http://www.phpv.net/uploadfile/month_200907/local_LfK9D1bCL3.jpg" width="600" />
				<br />Google Analytics 访问者/用户定义报告 </p>
		<p>分析豆瓣的源码可以知道，豆瓣对每一个登录后的用户，都赋以一个专门的 id 值，这样可以在用户定义报告里，看到整体的登录用户访问行为，乃至每个登录用户的浏览行为。通过这样设定后，豆瓣便可以轻易获取高忠诚度访问用户的访问行为。<a title="_setVar 设置说明" href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._setVar" target="_blank">关于_setVar()的更多说明，请参阅 Google Analytics的技术文档</a></p>
		<p>如何根据访问者在我的网站上访问的页面或在表单上做出的响应对其进行分类？<a title=" 如何根据访问者在我的网站上访问的页面或在表单上做出的响应对其进行分类？" href="http://www.google.com/support/googleanalytics/bin/answer.py?hlrm=en&amp;answer=57045" target="_blank">在 Google Analytics 官方的帮助文件，也给出了另外一个应用案例</a></p>
		<p>值得注意的是，原来在设置 <code>_setVar()</code> 函数的时候，整个网站的跳出率会出现重大的偏差，不过在<a title="Google Analytics修正_setVar函数对网站跳出率的影响" href="http://analytics.blogspot.com/2009/01/using-setvar-heres-update-on-bounce.html" target="_blank">最近的google analytics官方博客，指出该bug已经修正</a>，客户在进行这方面设置的时候，还是要注意对比前后数据是否有重大偏差。</p>
		<h2>通过 _trackPageview 区分不同类型的评论</h2>
		<p>豆瓣上的书评，影评和乐评可以说是豆瓣网站的核心价值所在。一般评论的URL格式如下：</p>
		<p style="TEXT-ALIGN: center">
				<img alt="豆瓣上单条评论的URL" src="http://www.phpv.net/uploadfile/month_200907/local_LP9SBYU5iw.jpg" />
				<br />豆瓣上单条评论的URL </p>
		<p>当我们查看该页面的网页源代码时，会发现有趣的现象:</p>
		<p style="TEXT-ALIGN: center">
				<img alt="豆瓣单条评论页的 Google Analytics 代码" src="http://www.phpv.net/uploadfile/month_200907/local_oBi5X9K3OC.jpg" />
				<br />豆瓣单条评论页的 Google Analytics 代码 </p>
		<p>我们知道，一般 Google Analytics 的<code>_trackPageview()</code> 括弧中的参数是留空的， Google Analytics 会自动捕获网址的 URL 参数，如果在 <code>_trackPageview()</code>括弧中输入特定的数值，那么在 Google Analytics 的报表中，URL 将是我们指定的参数，而不再是我们在地址栏看到的 URL。</p>
		<p>如上面的例子，我们在 Google Analytics 中看到的URL将是<span style="COLOR: rgb(255,0,0)">/book/review/1946018/</span>，而不再是我们在浏览器地址栏看到的<span style="COLOR: rgb(255,0,0)">/review/1946018/</span></p>
		<p>当所在频道是电影或者音乐时，<code>_trackPageview()</code> 中的参数将根据所在频道的属性，变为/movie/xxxxx 或者 /music/xxxxx的数值。</p>
		<p>豆瓣通过对的参数进行重新指定，主要有以下的好处：</p>
		<p>保证了用户和搜索引擎看到的 URL 比较简短，达到 URL 对用户友好和对搜索引擎友好的目的；而在 Google Analytics 报告中，通过 <span style="COLOR: rgb(255,0,0)">内容/内容细目/ </span>报告，又能了解到各个频道总的浏览情况。</p>
		<p>在GA的<span style="COLOR: rgb(255,0,0)">内容细目</span>报告中，将会多出 <span style="COLOR: rgb(255,0,0)">/book/ /music/ /movie/</span> 这样的文件夹来，总而获得各个频道的合计浏览数据。</p>
		<p>而如果只是使用默认 <code>_trackPageview()</code>，你将只能得到所有评论页面的浏览数据，而无法得到细分的各个频道的浏览数据。</p>
		<p>关于<code>_trackPageview()</code>的具体的使用方法<a title="_trackPageview中参数的使用" href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApi.html#_gat.GA_Tracker_._trackPageview" target="_blank">可参照 Google Code 的说明</a></p>
		<p>注意事项:使用 <code>_trackPageview()</code> 参数重新指定 URL 之后，网站覆盖图的数据将受到影响。<a href="http://www.google.com/support/analytics/bin/answer.py?hl=cn&amp;answer=66982" target="_blank">可参阅 Google Analytics 的官方帮助文件</a></p>
		<p>除了豆瓣使用 <code>_trackPageview()</code> 来对URL进行重写，<a href="http://www.dianping.com/" target="_blank">大众点评网</a>也采用了类似的做法（应该是比豆瓣更早采用。。。因为是我在点评网任职时候实验的做法;那时候豆瓣还没有使用 Google Analytis 统计代码，呵呵），有兴趣的同学可以自己去研究点评的 Google Analytis 代码。</p><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6824.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-08-07 11:05 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/08/07/6824.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>bat 里如何写 过10秒钟 执行某个命令</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/07/30/6798.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Thu, 30 Jul 2009 08:42:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/07/30/6798.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6798.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/07/30/6798.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6798.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6798.html</trackback:ping><description><![CDATA[bat 里如何写 过10秒钟 执行某个命令  这样的东西<br />用：<br /><font color="#ff0000">@ ping -n 10 127.0.0.1&gt;null</font><br /><br />可以这样变通，很好的呀。<br /><br /><br />天津促销网 <a href="http://www.tjcuxiao.com">http://www.tjcuxiao.com</a><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6798.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-07-30 16:42 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/07/30/6798.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用webftp上传压缩文件</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/07/05/6741.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Sat, 04 Jul 2009 19:23:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/07/05/6741.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6741.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/07/05/6741.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6741.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6741.html</trackback:ping><description><![CDATA[<div class="postmessage ">
				<h2>使用webftp上传压缩文件</h2>
				<p>btcuxiao.com 天津促销网</p>
				<div class="specialmsg">
						<table cellspacing="0" cellpadding="0">
								<tbody>
										<tr>
												<td class="t_msgfont" id="postmessage_25483">大家在往自己的FTP服务器里上传文件的时候，常常使用一些FTP客户端软件，例如CuteFTP或者flashFTP，他们都受到你的网络连接速度的限制，如果你的服务器在国外，很有可能上传一个BBS原程序会浪费你一天时间，其实它们也不大，但为什么就是上传的慢呢？因为每上传一个文件程序就会连接远程服务器的端口（socket），有时候因为网络的延时，端口常常连接失败，但如果你上传一个同样大小的文件（例如一个ZIP压缩包），也许很快就会上传过去，所以今天给大家介绍一个很好用的基于网络的FTP客户端软件 <font color="#ff0000">NET2FTP</font>，以后再介绍一个简单点的程序。<br /><font color="#ff0000">NET2FTP</font>的原理是把你要上传的文件先上传到NET2FTP所在的服务器，然后通过服务器再向远程的FTP服务器传送文件，大家要知道服务器的带宽很大，所以服务器对服务器的传输速度就会快的多，这样的话大家就可以通过别人架设好的NET2FTP传送文件。这里先给大家一个网站<a href="http://www.net2ftp.com/" target="_blank"><font color="#800080">http://www.net2ftp.com</font></a>，通过它你可以向一些封了IP的服务器传送自己的文件。还有个更方便的方法，你直接把软件安装到自己的FTP服务器上，这样速度会更快。<br />NET2FTP的一个<font color="#ff0000">最大的优点就是可以把zip, tar, tgz, gz结尾的压缩包在线解压缩</font>，这样你只需要把要上传的大量文件先用压缩软件如WINRAR或者WINZIP压缩成ZIP包，然后把压缩包上传，NET2FTP会自动把它在服务器上解压缩然后发送到远程FTP上，如果NET2FTP安装到自己的服务器上那就更好了，可以直接解压缩到服务器上，省掉了一个服务器到服务器的传输过程。<br />NET2FTP之安装<br /><font color="#ff0000">建议先看使用再看安装</font><br />1.先看看你自己的服务器是否符合条件，<font color="#ff0000">支持PHP</font>，版本至少是4.2.3（安全模式也没有问题），当然最好是版本越高越好，可以支持一些高级命令。<br />2.要有一定的空间，完整版的NET2FTP（包括全部的官方皮肤和插件）需要将近8Mb大小，还有个简化版的，3Mb左右（只有英语，皮肤一个，好象没有插件）。<br />如果你符合上面两个条件，恭喜你可以在自己的服务器上安装NET2FTP了。<br />3.下载安装包。我这里安装的是完全版。官方下载地址是<a href="http://www.net2ftp.com/homepage/download.html" target="_blank"><font color="#0000ff">http://www.net2ftp.com/homepage/download.html</font></a>，现在的最新版本是0.91a，<a href="http://www.net2ftp.com/download/net2ftp_v0.91a.zip" target="_blank"><font color="#0000ff">http://www.net2ftp.com/download/net2ftp_v0.91a.zip</font></a><br />4.解压缩所有的文件，在<font color="#ff0000">\files_to_upload里面 </font>找到<font color="#ff0000">settings.inc.php</font><font color="#000000">，这个是配置文件，用记事本打开它，</font><font color="#000000">我们来进行简单的设置。找到</font><br />$net2ftp_settings["default_language"] = " <font color="#ff0000">en</font>";（默认的语言英语，汉语版本有问题，不建议使用）<br />$net2ftp_settings["default_skin"]     = "<font color="#ff0000">india</font>";（皮肤，建议改成<font color="#ff0000">blue</font>，因为这个皮肤做的很完美）<br />$net2ftp_settings["admin_username"] = " <font color="#ff0000">admin</font>";（默认的管理员名称，可以修改）<br />$net2ftp_settings["admin_password"] = "";（默认为空，如果你要记录程序使用日志，添加密码即可）<br />$net2ftp_settings["max_upload_filesize"]  = "<font color="#ff0000"> 2000000</font>";  （文件最大上传大小，默认2M，根据需要修改）<br />$net2ftp_settings["use_database"] = "<font color="#ff0000">no</font>"; （是否记录登陆日志，默认NO，可修改为YES，别忘了把create_tables.sql导入到你的MySQL里面）<br />// Enter your MySQL settings（这里的几个要在上面那个选项为YES时填写）<br />$net2ftp_settings["dbusername"] = "";用户名<br />$net2ftp_settings["dbpassword"] = "";密码<br />$net2ftp_settings["dbname"]     = "";数据库名<br />$net2ftp_settings["dbserver"]   = "localhost"; 地址<br />$net2ftp_settings["max_consumption_ipaddress_dataTransfer"] = <font color="#ff0000">20000000</font>; // 每个IP每天最多传输文件字节$net2ftp_settings["max_consumption_ftpserver_dataTransfer"] = <font color="#ff0000">50000000</font>; // 每个FTP服务器最多接受字节<br />5.把文件上传到服务器上，<font color="#ff0000">/temp</font><font color="#000000">文件夹属性设置成777</font><br />6.（可选）如果你要记录登陆日志，导入create_tables.sql<br />NET2FTP之使用<br />大家配置好文件上传过后就可以开始使用NET2FTP了。<br />1.登陆FTP<br />填写FTP server（服务器地址），Username（用户名），PASSWORD（密码），点击login进入你的ftp服务器<br /><p align="left"><img height="309" alt="" src="http://docs.google.com/File?id=ajgqhkjx4s3x_187hhkktcfx" width="460" /><br /><br />2.主界面.大家可以简要的看一下，跟FTP软件有什么区别。<br /></p><p align="left"><img style="CURSOR: pointer" height="315" alt="" src="http://docs.google.com/File?id=ajgqhkjx4s3x_188frng3j3f" width="600" /></p><br /><br /><br />3.最右上角的四个分别是 添加到收藏夹/刷新/帮助/登出<br /><p align="left"><img height="122" alt="" src="http://docs.google.com/File?id=ajgqhkjx4s3x_189tddb3pd4" width="243" /><br /><br />4下面分别是 新建文件夹/新建文件/上传文件/JAVA上传/高级属性<br /><img height="98" alt="" src="http://lh5.google.com/toblogcn/RoOa-xhylGI/AAAAAAAACyU/YuyDsVPCxCM/eidt.jpg" width="400" border="0" /><br />5这几个大家都认识了 复制/移动/删除/重命名/属性/下载/压缩/大小/搜索</p><br /><p align="left"><img height="133" alt="" src="http://docs.google.com/File?id=ajgqhkjx4s3x_190fq37x6fz" width="308" /><br /><br />6.下面重点讲上传，点UPLOAD，出现这个画面<br /></p><p align="left"><img style="CURSOR: pointer" height="255" alt="" src="http://docs.google.com/File?id=ajgqhkjx4s3x_191gcxt2gfx" width="600" /><br /><br />我们来上传一个包含着许多图片的压缩包<br /></p><p align="left"><img height="220" alt="" src="http://docs.google.com/File?id=ajgqhkjx4s3x_192fbh8qtcs" width="373" /><br /><br />点右边的archives（存档）浏览，选择一个压缩文件，然后再点那个对号，等他上传吧。 </p><p align="left"><img style="CURSOR: pointer" height="250" alt="" src="http://docs.google.com/File?id=ajgqhkjx4s3x_194c4nqcwdn" width="600" /></p><br /><br /><br /><p align="left">上传完成后程序会自动解压缩<br /><img style="CURSOR: pointer" height="299" alt="" src="http://docs.google.com/File?id=ajgqhkjx4s3x_193f5jgtvcd" width="600" /><br />至此，大功告成<br />------------------------------------------------------------------------<br />hoho,其实写这个东西还是满辛苦的，花了不少时间，希望能给大家带来方便，最后再给大家个使用net2ftp的网站，就是<a href="http://www.net2ftp.com/" target="_blank"><font color="#800080"></font></a><font color="#800080"><a href="http://www.net2ftp.com/" target="_blank">http://www.net2ftp.com/</a></font>啦，其实还有类似的网站，像WEB2FTP是一样的道理啊。有好多空间都已经支持在线解压缩了，网站的后台工具就有，像CP空间，大家可以灵活的使用它们，能节省相当多的时间啊。 </p><br /><br /><strong>使用</strong><a href="http://liwish.com/2008/02/19/12.html" target="_blank">CMSware-ZIP在线解压</a><br /><br />现在说要说的<strong>CMSware</strong>是一种用于解压WEB服务器空间里面的压缩文件，对于使用国外空间的用户来说，这个也是解决FTP上传速度慢的！已经经过测试，解压速度很不错！<br />1.运行环境：程序运行需要php支持Session和zlib扩展 9<br />2.适用范围：传输文件很多的时候，一个个文件传输往往使得FTP速度慢了许多，把这些文件压缩成zip，然后传输该zip包到你的空间，这样速度会快许多，然后再通过本软件把zip压缩包在空间里面直接还原成一个个文件<br />3,使用方法<br />将<a href="http://www.box.net/shared/static/cfrhemjxi1.zip" target="_blank">本程序</a>通过FTP上传到web服务器空间里面，第一次运行时将会要求设定管理员账号、密码，以后用此次的设定登录,进行解压缩<br />5, 在线解压步骤:<br />将您需要上传的网页程序打包成zip压缩包(可用winzip或者winrar压缩),上传到解压程序有权访问的任意位置，然后通过浏览器打开本程序,本程序会在”ZIP文档”处自动列出压缩包，点击”解压”即可<br /><font color="#ff00">6,注意事项<br /></font>(1)请不要使用太大的压缩包，一般服务器解压8MB以内的压缩包应该没有问题.如果你的文件很多,可以分成多个压缩包(注意是分开压缩,而不是分卷压缩)<br />(2)在非Windows环境下将压缩包解压以后若所解压的程序的安装使用出现问题请认真检查程序的目录和文件权限<br />(3)<strong>程序只支持zip压缩包的解压</strong><br /><a href="http://www.box.net/shared/static/cfrhemjxi1.zip" target="_blank">点此下载</a><br /></td>
										</tr>
								</tbody>
						</table>
				</div>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6741.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-07-05 03:23 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/07/05/6741.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>strlen、mb_strlen计算中英文混排字符串长度</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/07/02/6737.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Thu, 02 Jul 2009 06:26:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/07/02/6737.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6737.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/07/02/6737.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6737.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6737.html</trackback:ping><description><![CDATA[<p>在php中常见的计算字符串长度的函数有：strlen和mb_strlen，下面是对这两个函数的比较说明（编码方式UTF8）</p>
		<ul>
				<li>比较strlen和mb_strlen<br />当字符全是英文字符的时候，两者是一样。这里主要比较一下，中英文混排的时候，两个计算结果。（测试时编码方式是UTF8）<br /><span id="more-17"></span><p></p><div class="hl-surround"><ol class="hl-main ln-show" ondblclick="linenumber(this)" title="Double click to hide line number."><li class="hl-firstline"><span style="COLOR: blue">&lt;?php</span></li><li><span style="COLOR: #00008b">$str</span><span style="COLOR: gray">=</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: red">中文a字1符</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: gray">;</span></li><li><span style="COLOR: green">echo</span><span style="COLOR: gray"> </span><span style="COLOR: blue">strlen</span><span style="COLOR: olive">(</span><span style="COLOR: #00008b">$str</span><span style="COLOR: olive">)</span><span style="COLOR: gray">;</span></li><li><span style="COLOR: green">echo</span><span style="COLOR: gray"> </span><span style="COLOR: #8b0000">‘</span><span style="COLOR: red">&lt;br /&gt;</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: gray">;</span></li><li><span style="COLOR: green">echo</span><span style="COLOR: gray"> </span><span style="COLOR: blue">mb_strlen</span><span style="COLOR: olive">(</span><span style="COLOR: #00008b">$str</span><span style="COLOR: gray">,</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: red">UTF8</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: olive">)</span><span style="COLOR: gray">;</span></li><li><span style="COLOR: #ffa500">//输出结果</span></li><li><span style="COLOR: #ffa500">//14</span></li><li><span style="COLOR: #ffa500">//6</span></li><li><span style="COLOR: blue">?&gt;</span></li></ol></div><p><strong>结果分析：</strong>在strlen计算时，对待一个UTF8的中文字符是3个长度，所以“中文a字1符”长度是3*4+2=14<br />在mb_strlen计算时，选定内码为UTF8，则会将一个中文字符当作长度1来计算，所以“中文a字1符”长度是6 </p></li>
				<li>
						<span style="COLOR: #ff0000">
								<strong>关于中英文混排串的占位符计算：<br /></strong>
						</span>利用这两个函数则可以联合计算出一个中英文混排的串的占位是多少（一个中文字符的占位是2，英文字符是1），计算的方法是：如果一个混排字符串有a个中文，b个英文，占位是: 
<p></p><div class="hl-surround"><ol class="hl-main ln-hide" ondblclick="linenumber(this)" title="Double click to show line number."><li class="hl-firstline"><span style="COLOR: blue">&lt;?php</span></li><li><span style="COLOR: #00008b">$str</span><span style="COLOR: gray">=</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: red">中文a字1符</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: gray">;</span></li><li><span style="COLOR: #ffa500">//计算如下</span></li><li><span style="COLOR: green">echo</span><span style="COLOR: gray"> </span><span style="COLOR: olive">(</span><span style="COLOR: gray"></span><span style="COLOR: blue">strlen</span><span style="COLOR: olive">(</span><span style="COLOR: #00008b">$str</span><span style="COLOR: olive">)</span><span style="COLOR: gray"> + </span><span style="COLOR: blue">mb_strlen</span><span style="COLOR: olive">(</span><span style="COLOR: #00008b">$str</span><span style="COLOR: gray">,</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: red">UTF8</span><span style="COLOR: #8b0000">‘</span><span style="COLOR: olive">)</span><span style="COLOR: gray"></span><span style="COLOR: olive">)</span><span style="COLOR: gray"> / </span><span style="COLOR: maroon">2</span><span style="COLOR: gray">;</span></li><li><span style="COLOR: green">echo</span></li><li><span style="COLOR: #ffa500">//输出结果</span></li><li><span style="COLOR: #ffa500">//10</span></li><li><span style="COLOR: blue">?&gt;</span></li></ol></div><p>例如 <strong> “中文a字1符” </strong>的strlen($str)值是14，mb_strlen($str)值是6，则可以计算出“中文a字1符”的占位是<strong>10</strong>.</p></li>
		</ul><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6737.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-07-02 14:26 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/07/02/6737.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>js中用undefined作判断条件</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/24/6722.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Wed, 24 Jun 2009 06:17:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/24/6722.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6722.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/24/6722.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6722.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6722.html</trackback:ping><description><![CDATA[js的一个小问题：<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img id="Codehighlighter1_14_40_Open_Image" onclick="this.style.display='none'; Codehighlighter1_14_40_Open_Text.style.display='none'; Codehighlighter1_14_40_Closed_Image.style.display='inline'; Codehighlighter1_14_40_Closed_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_14_40_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_14_40_Closed_Text.style.display='none'; Codehighlighter1_14_40_Open_Image.style.display='inline'; Codehighlighter1_14_40_Open_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(undefined) </span><span id="Codehighlighter1_14_40_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"></span><span id="Codehighlighter1_14_40_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/InBlock.gif" align="top" />   alert('不报错，不运行该语句');<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000">;<br /><img id="Codehighlighter1_58_84_Open_Image" onclick="this.style.display='none'; Codehighlighter1_58_84_Open_Text.style.display='none'; Codehighlighter1_58_84_Closed_Image.style.display='inline'; Codehighlighter1_58_84_Closed_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_58_84_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_58_84_Closed_Text.style.display='none'; Codehighlighter1_58_84_Open_Image.style.display='inline'; Codehighlighter1_58_84_Open_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">undefined) </span><span id="Codehighlighter1_58_84_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"></span><span id="Codehighlighter1_58_84_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/InBlock.gif" align="top" />   alert('不报错，要运行该语句');<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span></div><h1><a herf="http://www.btcuxiao.comi">BT促销</a></h1><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6722.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-24 14:17 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/24/6722.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>剖析PHP中的输出缓冲 </title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/23/6721.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Tue, 23 Jun 2009 02:11:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/23/6721.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6721.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/23/6721.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6721.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6721.html</trackback:ping><description><![CDATA[<p> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">我们先来看一段代码。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">--</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">flush</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">sleep</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />按照php手册里的说法<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    该函数将当前为止程序的所有输出发送到用户的浏览器。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />上面的这段代码，应该隔一秒钟输出一次</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">。但是实际中却不一定是这样。有可能是等了10秒钟后，所有的输出同时呈现出来。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />好，我们来改一下这段代码，改成<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #008080">ob_end_clean</span>
				<span style="COLOR: #000000">();</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">修改部分</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">--</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">flush</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">sleep</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />嘿，加了这一句ob_end_clean();</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">居然就OK了。实际上，我们把ob_end_clean()换成ob_end_flush()也一样OK。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />我再来改一改。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">--</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">ob_flush</span>
				<span style="COLOR: #000000">();</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">修改部分</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #008080">flush</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">sleep</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />运行一下，是不是发现</span>
				<span style="COLOR: #800080">$i也隔一秒输出一次了</span>
				<span style="COLOR: #000000">？这是为什么呢？<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />别急，我们来看看php</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">ini。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />打开php</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">ini</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">搜索output_buffering，我们会看到类似这样的设置 output_buffering </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">4096</span>
				<span style="COLOR: #000000">。正如它的名字output_buffering一样，这个设置的作用就是把输出缓冲一下，缓冲大小为4096bytes</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />在我们的第一段代码里，之所以没有按预期的输出，正是因为这个output_buffering把那些输出都缓冲了。没达到4096bytes或者脚本结束，输出是不会被发送出去的。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />而第二段代码中的ob_end_clean()和ob_end_flush()的作用，就是终止缓冲。这样就不用等到有4096bytes的缓冲之后才被发送出去了。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />第三段代码中，用了一句ob_flush()</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">它的作用就是把缓冲的数据发送出去，但是并不会终止缓冲，所以它必须在每次flush()前使用。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />如果不想使用ob_end_clean()</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">ob_end_flush</span>
				<span style="COLOR: #000000">()和ob_flush()，我们就必须把php</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">ini里的 output_buffering设得足够小，例如设为0。需要注意的是，如果你打算在脚本中使用 </span>
				<span style="COLOR: #008080">ini_set</span>
				<span style="COLOR: #000000">(”output_buffering”</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">”</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">″)来设置，那么请停下来吧，这种方法是不行的。因为在脚本一开始的时候，缓冲设置就已经被载入，然后缓冲就开始了。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />可能你会问了，既然ob_flush()是把缓冲的数据发送出去，那么为什么还需要用flush()</span>
				<span style="COLOR: #000000">???</span>
				<span style="COLOR: #000000">直接用下面这段代码不行吗？？<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">--</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">ob_flush</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">sleep</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />请注意ob_flush()和flush()的区别。前者是把数据从PHP的缓冲中释放出来，后者是把不在缓冲中的或者说是被释放出来的数据发送到浏览器。所以当缓冲存在的时候，我们必须ob_flush()和flush()同时使用。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />那是不是flush()在这里就是不可缺少的呢？不是的，我们还有另外一种方法，使得当有数据输出的时候，马上被发送到浏览器。下面这两段代码就是不需要使用flush()了。（当你把output_buffering设为0的时候，连ob_flush()和ob_end_clean()都不需要了）<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #008080">ob_implicit_flush</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #0000ff">true</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">--</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">ob_flush</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">sleep</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #008080">ob_end_clean</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #008080">ob_implicit_flush</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #0000ff">true</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">--</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008080">sleep</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />请注意看上面的ob_implicit_flush(</span>
				<span style="COLOR: #0000ff">true</span>
				<span style="COLOR: #000000">)，这个函数强制每当有输出的时候，即刻把输出发送到浏览器。这样就不需要每次输出（</span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000">）后，都用flush()来发送到浏览器了。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />以上所诉可能在某些浏览器中不成立。因为浏览器也有自己的规则。我是用Firefox1</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">IE6</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">opera8</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">5来测试的。其中opera就不能正常输出，因为它有一个规则，就是不遇到一个HTML标签，就绝对不输出，除非到脚本结束。而FireFox和IE还算比较正常的。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />最后附上一段非常有趣的代码</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">作者为PuTTYshell。在一个脚本周期里，每次输出，都会把前一次的输出覆盖掉。<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />以下代码只在firefox下可用，其他浏览器并不支持multipart</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">x</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #0000ff">mixed</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">replace的Content</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">Type</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #008080">header</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">Content-type: multipart/x-mixed-replace;boundary=endofsection</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">\n--endofsection\n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #800080">$pmt</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">array</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">\\</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> );<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000">( </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000"> ){<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #008080">sleep</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Content-type: text/plain\n\n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Part $i\t</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #800080">$pmt</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">--endofsection\n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #008080">ob_flush</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #008080">flush</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Content-type: text/plain\n\n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">The end\n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">--endofsection--\n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6721.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-23 10:11 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/23/6721.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BT促销部分大学的重点特色专业介绍</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/19/6713.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Fri, 19 Jun 2009 01:25:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/19/6713.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6713.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/19/6713.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6713.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6713.html</trackback:ping><description><![CDATA[<span class="ArticleTitleText">
				<div id="ArticleBlogButtons" style="MARGIN-BOTTOM: 4px" align="right">
						<a id="link_VoteArticle_Top" title="给这篇文章投一票" href="http://tjfuyongjie.blog.hexun.com/34006337_d.html#">
								<img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; VERTICAL-ALIGN: middle; CURSOR: pointer; BORDER-RIGHT-WIDTH: 0px" alt="我顶" src="http://blog.hexun.com/img/btn-newding.gif" />
						</a>
						<span id="ChangeBlogArticleFont" style="FONT-SIZE: 12px; VERTICAL-ALIGN: middle">字号：<span id="btnBigFont" style="FONT-WEIGHT: normal; CURSOR: pointer" onclick="javascript:changeFont(1);">大</span><span id="btnNormalFont" style="FONT-WEIGHT: bold; CURSOR: default" onclick="javascript:changeFont(2);">中</span><span id="btnSmallFont" style="FONT-WEIGHT: normal; CURSOR: pointer" onclick="javascript:changeFont(3);">小</span></span>
				</div>
				<div id="BlogArticleDetail" style="FONT-SIZE: 14px">
						<p>在<a href="http://www.btcuxiao.com/" target="_blank">BT促销</a>（<a href="http://www.btcuxiao.com/">http://www.btcuxiao.com</a>）重点促销高考高校信息，这些信息主要是部分省市的某些高校的重点专业和特色专业，面向重点线及以下分数考生选择，例如：</p>
						<div class="province">湖北省</div>
						<div class="school">1. <a href="http://kaoshi.edu.sina.com.cn/college/c/10495.shtml">武汉科技学院 </a></div>
						<div class="introduce">    学校纺织、服装、艺术设计学科优势特色明显。服装学院是全国高校最早建立的服装院系之一，连续九年居全国服装院校“新人奖”“育人奖”综合积分第一名，被中国服装设计师协会授予中国“十大时装名校”荣誉称号。艺术设计专业为首批省级品牌专业，并获批首批国家特色专业。<br />    学校拥有电工电子、大学物理2个湖北省实验教学示范中心；拥有艺术设计（服装艺术设计）、纺织工程、建筑环境与设备工程、轻化工程、机械设计制造及其自动化等 5 个湖北省品牌专 </div>
						<div class="school">2. <a href="http://kaoshi.edu.sina.com.cn/college/c/10525.shtml">湖北汽车工业学院（十堰市） </a></div>
						<div class="introduce">    2000年机械设计制造及其自动化列为教育部控制与管理的本科专业。2001年机械制造及其自动化学科被批准为湖北省重点建设学科，材料加工工程学科于1998年被批准为省级重点建设学科。 </div>
						<div class="school">3.<a href="http://kaoshi.edu.sina.com.cn/college/c/10496.shtml">武汉工业学院</a></div>
						<div class="introduce">    “机械设计制造及其自动化”为省级重点学科。生物化工学科2001年被批准为湖北省省级重点学科。 </div>
						<div class="school">4. <a href="http://kaoshi.edu.sina.com.cn/college/c/50036.shtml">长江大学</a></div>
						<div class="introduce">    湖北省重点学科（矿产普查与勘探）、湖北省有突出成就的创新学科(矿产普查与勘探),湖北省品牌本科专业（资源勘查工程），湖北省精品课程（沉积岩石学）。应用地球物理省级重点学科；信号与信息处理学科于 2001 年被列为湖北省省级重点学科。“应用化学” 学科是湖北省重点学科。石油天然气机械工程学科被评为湖北省重点学科。 </div>
						<div class="school">5. <a href="http://kaoshi.edu.sina.com.cn/college/c/11934.shtml">三峡大学（宜昌）</a></div>
						<div class="introduce">    类型：综合隶属于：湖北省教育厅国家重点学科：12个院士：11人博士点：0个硕士点：32个 免疫学省级重点学科，硕士点8个（含立项在建）；病理学、组织学与胚胎学、药理学、预防医学、生理学、医学影像诊断学为校级精品课程；省级重点学科—机械制造及自动化和校级重点学科—机械设计及理论。湖北省重点学科—减灾防灾及防护工程。 </div>
						<div class="school">6. <a href="http://kaoshi.edu.sina.com.cn/college/c/50230.shtml">湖北工业大学 </a></div>
						<div class="introduce">    类型：工科隶属于：湖北省教育厅国家重点学科：17个院士：0人博士点：5个硕士点：51个 1984年，湖北省委、省政府将湖北轻工业学院（当时中南地区唯一的一所轻工类本科院校）和湖北农业机械专科学校合并组建湖北工学院（即学校前身）。 其中有2个国家特色专业建设点、7个湖北省品牌专业、13门省级精品课程。 </div>
						<div class="introduce"> </div>
						<div class="introduce">请点击 <a href="http://www.btcuxiao.com/" target="_blank">BT促销网</a> 查看更多的信息，会持续更新中...</div>
				</div>
		</span><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6713.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-19 09:25 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/19/6713.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php图像函数大举例（非原创）</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/15/6706.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Mon, 15 Jun 2009 10:14:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/15/6706.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6706.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/15/6706.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6706.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6706.html</trackback:ping><description><![CDATA[<h1>
				<a href="http://www.btcuxiao.com">
						<font color="gray">BT促销</font>
				</a>
		</h1>
		<div>
				<br />PHP自4.3版本开始,捆绑了自己的GD2库,用户可以自己下载并设置.如果要查看自己的php版本是否支持gd模块(支持JPEG,PNG,WBMP但不再支持GIF),如下方式是一种方法:<br /></div>
		<br />
		<div>
				<br />
				<pre class="CodeSamp">if(!function_exists('imagecreate')) {<br />
die('本服务器不支持GD模块');<br />
}<br /></pre>
				<br />
		</div>
		<br />
		<div>
				<br />如果不支持的话,如何配置 ? 下载gd模块的dll文件,修改php.ini,重启服务器即可.<br /><br /><br />以下简称PHP作图为PS.<br /><br />当您打算 PS的话,应该完成如下如下步骤,这是<b>必经</b>的.<br /><br />1:创建基本PS对象(我假设为$image),填充背景(默认黑),以后的全部ps操作都是基于这个背景图像的.<br />2:在$image上作图.<br />3:输出这个图像.<br />4:销毁对象,清除使用内存.<br /><br />首先,我们来认识几个常用的函数,这些函数在php手册里面都有详细介绍,此处大体引用下.<br /><br />resource <font color="#0d00e0">imagecreate</font> ( int x_size, int y_size )<br /><font color="#0d00e0">imagecreate() </font>返回一个图像标识符，代表了一幅大小为 x_size 和 y_size 的空白图像。<br /><br />此函数基本同<font color="#0d00e0">imagetruecolor</font>($width,$height).<br />---------------------------------------------------------<br />int <font color="#0d00e0">imagecolorallocate </font>( resource image, int red, int green, int blue )<br /><br /><br /><font color="#0d00e0">imagecolorallocate()</font> 返回一个标识符，代表了由给定的 RGB 成分组成的颜色。image 参数是 imagecreatetruecolor() 函数的返回值。red，green 和 blue 分别是所需要的颜色的红，绿，蓝成分。这些参数是 0 到 255 的整数或者十六进制的 0x00 到 0xFF。imagecolorallocate() 必须被调用以创建每一种用在 image 所代表的图像中的颜色。<br /><br />---------------------------------------------------------<br />bool <font color="#0d00e0">imagefill</font> ( resource image, int x, int y, int color )<br /><br /><font color="#0d00e0">imagefill()</font> 在 image 图像的坐标 x，y（图像左上角为 0, 0）处用 color 颜色执行区域填充（即与 x, y 点颜色相同且相邻的点都会被填充）。<br /><br />---------------------------------------------------------<br />bool <font color="#0d00e0">imageline </font>( resource image, int x1, int y1, int x2, int y2, int color )<br /><br /><br /><font color="#0d00e0">imageline()</font> 用 color 颜色在图像 image 中从坐标 x1，y1 到 x2，y2（图像左上角为 0, 0）画一条线段。<br />--------------------------------------------------------- <br /><br />bool <font color="#0d00e0">imagestring </font>( resource image, int font, int x, int y, string s, int col )<br /><br /><br /><font color="#0d00e0">imagestring()</font> 用 col 颜色将字符串 s 画到 image 所代表的图像的 x，y 坐标处（这是字符串左上角坐标，整幅图像的左上角为 0，0）。如果 font 是 1，2，3，4 或 5，则使用内置字体。<br /><br />---------------------------------------------------------<br />array <font color="#0d00e0">imagettftext </font>( resource image, float size, float angle, int x, int y, int color, string fontfile, string text )<br /><br />本函数比较重要,参数较多,此处不再列出,它主要是写字到图像上,和上面的函数类似,但必前者强大.<br />---------------------------------------------------------<br />bool <font color="#0d00e0">imagefilltoborder </font>( resource image, int x, int y, int border, int color )<br /><br /><br /><font color="#0d00e0">imagefilltoborder() </font>从 x，y（图像左上角为 0, 0）点开始用 color 颜色执行区域填充，直到碰到颜色为 border 的边界为止。【注：边界内的所有颜色都会被填充。如果指定的边界色和该点颜色相同，则没有填充。如果图像中没有该边界色，则整幅图像都会被填充。】<br /><br />------------------------------------------------<br /><br /><br />bool <font color="#0d00e0">imagefilledellipse </font>( resource image, int cx, int cy, int w, int h, int color )<br /><br /><br /><font color="#0d00e0">imagefilledellipse()</font> 在 image 所代表的图像中以 cx，cy（图像左上角为 0, 0）为中心画一个椭圆。w 和 h 分别指定了椭圆的宽和高。椭圆用 color 颜色填充。如果成功则返回 TRUE，失败则返回 FALSE。<br /><br />=================================================<br /><br />输出图像数据:<font color="#00a000"><b>imagepng($image[,$filename])</b></font></div>
		<br />
		<p>======================================================</p>
		<br />
		<div class="pubBody">
				<b>
						<font color="#ff0000">例一:输出蓝色背景和交叉白线的图形</font>
				</b>
				<br />
				<br />
				<br />
				<br />
				<pre class="CodeSamp">&amp;lt;?php<br />
$width=35;<br />
$height=35;<br />
//创建对象<br />
$image=imagecreate($width,$height);<br />
//提取颜色<br />
$color_white=imagecolorallocate($image,255,255,255);//白色<br />
$color_blue=imagecolorallocate($image,0,0,108);//蓝色<br />
imagefill($image,0,0,$color_blue);<br />
//作图<br />
//线宽<br />
imagesetthickness($image,3);<br />
imageline($image,0,0,$width,$height ,$color_white);<br />
imageline($image,$width,0,0,$height ,$color_white);<br />
//发送对象至头<br />
header('content-type:image/png');<br />
imagepng($image);<br />
/*<br />
//发送对象至文件<br />
$filename=&amp;quot;ex1.png&amp;quot;;<br />
imagepng($image,$filename);<br />
*/<br />
//销毁对象<br />
imagedestroy($image);<br />
?&amp;gt;</pre>
				<br />
				<br />
				<br />输出图像:<a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/12/2453242_1_ex1.png" target="_blank"><img alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/12/2453242_1_ex1.png" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br /><br /><b><font color="#00ed00">在线演示</font></b>:<a href="http://www.phzzy.org/temp/5do8/ex1.php" target="_blank">http://www.phzzy.org/temp/5do8/ex1.php</a></div>
		<br />
		<p> </p>
		<br />
		<div class="pubBody">
				<b>
						<font color="#ff0000">例二: 阴阳图</font>
				</b>
				<br />
				<br />
				<br />
				<pre class="CodeSamp">&amp;lt;?php<br />
$width=400;<br />
$height=400;<br />
$image=imagecreatetruecolor($width,$height);<br />
//提取颜色<br />
$color_black=imagecolorallocate($image,0,2,0);//<br />
$color_white=imagecolorallocate($image,255,255,255);//白色<br />
$color_blue=imagecolorallocate($image,0,0,108);//蓝色<br />
$color_red=imagecolorallocate($image,151,0,4);//红色<br />
$color_my=imagecolorallocate($image,192,192,255);//背景<br />
$color_temp=imagecolorallocate($image,199,199,199);//背景<br />
//作图<br />
imagefill($image,0,0,$color_white);<br />
//第一个是大圆<br />
imagefilledarc ($image,$width/2,$height/2,$height,$height,0,360,$color_blue,IMG_ARC_PIE);<br />
//两个小圆<br />
imagefilledellipse ($image,$width/2,$height/4 ,$height/2,$height/2,$color_red);<br />
imagefilledellipse ($image,$width/2,$height/4 * 3,$height/2,$height/2,$color_blue);<br />
/*imagefilledellipse -- 画一椭圆并填充*/<br />
imagefilledarc ($image,$width/2,$height/2,$height,$height,-90,90,$color_red,IMG_ARC_PIE);<br />
imagefilledellipse ($image,$width/2,$height/4 * 3,$height/2,$height/2,$color_blue);<br />
//发送对象至头<br />
header('content-type:image/png');<br />
imagepng($image);<br />
/*<br />
//发送对象至文件<br />
$filename=&amp;quot;ex1.png&amp;quot;;<br />
imagepng($image,$filename);<br />
*/<br />
//销毁对象<br />
imagedestroy($image);<br />
?&amp;gt;</pre>
				<br />
				<br />
				<br />
				<a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/12/2453268_1_ex2.png" target="_blank">
						<img height="379" alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/12/2453268_1_ex2.png" width="379" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" />
				</a>
				<br />
				<br />演示:<br /><a href="http://www.phzzy.org/temp/5do8/ex2.php" target="_blank">http://www.phzzy.org/temp/5do8/ex2.php</a><br /></div>
		<br />
		<p> </p>
		<br />
		<div class="pubBody">
				<b>
						<font color="#ff0000">例三:3D图像--cool</font>
				</b>
				<br />
				<br />
				<br />
				<pre class="CodeSamp">&amp;lt;?php<br />
$width=400;<br />
$height=400;<br />
$image = imagecreatetruecolor($width, $height);<br />
$white    = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);<br />
$gray     = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);<br />
$darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);<br />
$navy     = imagecolorallocate($image, 0x00, 0x00, 0x80);<br />
$darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);<br />
$red      = imagecolorallocate($image, 0xFF, 0x00, 0x00);<br />
$darkred  = imagecolorallocate($image, 0x90, 0x00, 0x00);<br />
imagefill($image,0,0,$white);<br />
// make the 3D effect<br />
for ($i = $height /2 +20; $i &amp;gt; $height /2; $i--) {<br />
imagefilledarc($image, $width/2, $i, $width/2, $height /2, 0, 45, $darknavy, IMG_ARC_PIE);<br />
imagefilledarc($image,  $width/2, $i, $width/2, $height /2, 45, 75 , $darkgray, IMG_ARC_PIE);<br />
imagefilledarc($image,  $width/2, $i, $width/2, $height /2, 75, 360 , $darkred, IMG_ARC_PIE);<br />
}<br />
imagefilledarc($image, $width/2, $height /2, $width/2, $height /2, 0, 45, $navy, IMG_ARC_PIE);<br />
imagefilledarc($image, $width/2, $height /2, $width/2, $height /2, 45, 75 , $gray, IMG_ARC_PIE);<br />
imagefilledarc($image, $width/2, $height /2, $width/2, $height /2, 75, 360 , $red, IMG_ARC_PIE);<br />
// flush image<br />
header('Content-type: image/png');<br />
imagepng($image);<br />
imagedestroy($image);<br />
/*<br />
//发送对象至文件<br />
$filename=&amp;quot;ex1.png&amp;quot;;<br />
imagepng($image,$filename);<br />
*/<br />
?&amp;gt;<br /></pre>
				<br />
				<br />
				<br />输出:<br /><br /><a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/12/2453270_1_ex3.png" target="_blank"><img height="383" alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/12/2453270_1_ex3.png" width="383" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br />演示:<a href="http://www.phzzy.org/temp/5do8/ex3.php" target="_blank">http://www.phzzy.org/temp/5do8/ex3.php</a><br /><br /></div>
		<br />
		<p> </p>
		<br />
		<div class="pubBody">
				<b>
						<font color="#ff0000">例四:简单的验证码</font>
				</b>
				<br />
				<br />PHP创建验证码非常容易,容易的要死,简单的思路是这样的:<br /><br />随机种子生成,提取随机字符,相连打印到图形,输出.,为了防止色盲,可以随机提取颜色,也可以自定义颜色,下面看看:<br /><br /><pre class="CodeSamp">&amp;lt;?php<br />
session_start();<br />
$width=65;<br />
$height=20;<br />
$sourcestrings=&amp;quot;0123456789aqwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM&amp;quot;;<br />
$image=imagecreate($width,$height);<br />
$colorarrs=array(<br />
imagecolorallocate($image,255,255,255),//white<br />
imagecolorallocate($image,0  ,0  ,  0)//black<br />
);<br />
unset($sessionval);<br />
imagesetthickness($image,3);<br />
//随机得到字符串个数<br />
$strsize=rand(3,5);<br />
imagefill($image,0,0,$colorarrs[0]);<br />
//一个个的写字符串到图片<br />
for($i=0;$i&amp;lt;$strsize;$i++){<br />
$i_temp=rand(1,62);<br />
$sessionval .=$sourcestrings[$i_temp];<br />
$fontcolor=imagecolorallocate($image,rand(0,255),rand(0,255),rand(0,255));<br />
$y_i = $height/2 + $font_size /3 ;<br />
imagechar($image,5, 1+ $i * $width /$strsize,5,$sourcestrings[$i_temp],$fontcolor);<br />
}<br />
//写入session,以后验证用<br />
unset($_SESSION['cjjer']);<br />
$_SESSION['cjjer'] = $sessionval;<br />
//添加杂点<br />
for($i=0;$i&amp;lt;$width /$height *2;$i++)<br />
{    $i_x=rand(0,$width);<br />
$i_y=rand(0,$height);<br />
$pixelcolor=imagecolorallocate($image,rand(0,255),rand(0,255),rand(0,255));<br />
imagesetpixel($image,$i_x,$i_y,$pixelcolor);<br />
}<br />
header('content-type:image/png');<br />
imagepng($image);<br />
imagedestroy($image);<br />
?&amp;gt;<br /></pre><br /><br /><br />生成的样式演示:<br /><a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_1_59ex4.png" target="_blank"><img alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_1_59ex4.png" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br /><a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_2_56ex4.png" target="_blank"><img alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_2_56ex4.png" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br /><a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_3_29ex4.png" target="_blank"><img alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_3_29ex4.png" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br />在线演示:<b><font color="#ff0000"><a href="http://www.phzzy.org/temp/5do8/ex4_login.php" target="_blank">http://www.phzzy.org/temp/5do8/ex4_login.php</a></font></b><br /><br /><br />有个很明显的问题就是生成的图片不够艳丽,从而很多的用户看起来不清楚,这样吧,我们自己设定几个比较艳丽的颜色然后输出,扩展colorarrs数组:<br /><br /><pre class="CodeSamp">$colorarrs=array(<br />
imagecolorallocate($image,255,255,255),<br />
imagecolorallocate($image,0,0,0),<br />
imagecolorallocate($image,0,70,0),<br />
imagecolorallocate($image,92,0,12),<br />
imagecolorallocate($image,0,0,128),<br />
imagecolorallocate($image,233,10,216)<br />
);<br /></pre><br /><br />然后把23行变为(17行):<br /><br /><pre class="CodeSamp">    $fontcolor=$colorarrs[rand(1,count($colorarrs)-1)];<br /></pre><br /><br /><br />输出:<a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_4_16ex4.png" target="_blank"><img alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_4_16ex4.png" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br /><br /><a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_5_24ex4.png" target="_blank"><img alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_5_24ex4.png" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br /><a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_6_37ex4.png" target="_blank"><img alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454559_6_37ex4.png" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br />在线演示:<b><font color="#ff0000"><a href="http://www.phzzy.org/temp/5do8/ex5_login.php" target="_blank">http://www.phzzy.org/temp/5do8/ex5_login.php</a></font></b></div>
		<br />
		<p> </p>
		<br />
		<p>
				<strong>
						<font color="#ff0000">例五:大点的比较cool的验证码 <br /><br /></font>
				</strong>PS 的图像还是比较小的,有时候为了某些原因(个人站点为了玩cool,just我,商业站点玩风格,吸引用户,just google,后话),验证码不是局限于十几个px的限制,有时候完全可以整个2百多,没啥问题,这时候,一种方案是把前面生成的小图强制大点,可以不? 可以,但是,看起来不够光滑,这是事实,明显,宽带不再是最重要的问题,不说其他的,下面演示几个比较好看的生成方式:<br /><br /></p>
		<br />
		<pre class="CodeSamp">&amp;lt;?php<br />
session_start();<br />
$width=600;<br />
$height=100;<br />
if($height  &amp;lt; $width /6)<br />
$height=$width / 4;<br />
$sourcestrings=&amp;quot;0123456789aqwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM&amp;quot;;<br />
//创建对象<br />
$image=imagecreate($width,$height);<br />
$white=imagecolorallocate($image,255,255,255);<br />
imagefill($image,0,0,$white);<br />
//加载字体库<br />
$fonts= dirname(__FILE__);<br />
putenv('&amp;quot;gdfontpath=&amp;quot;.$fonts=.&amp;quot;&amp;quot;');<br />
$fontname='arial';<br />
$font_size=floor($height / 2);<br />
//得到字符串<br />
unset($sessionval);<br />
$strsize=rand(5,8);<br />
for($i=0;$i&amp;lt;$strsize;$i++){<br />
$i_temp=rand(1,62);<br />
$sessionval .=$sourcestrings[$i_temp];<br />
$x_i =$font_size + $i *$width / ($strsize+1);<br />
$y_i = $height / 2;<br />
$angle_i=rand(-120,120);<br />
$fontcolor_a=imagecolorallocate($image,rand(0,255),rand(0,255),rand(0,255));<br />
imageTTFText($image,$font_size,$angle_i,$x_i,$y_i,$fontcolor_a,$fontname,$sourcestrings[$i_temp]);<br />
}<br />
unset($_SESSION['cjjer']);<br />
$_SESSION['cjjer'] = $sessionval;<br />
//杂点数目<br />
for($i=0;$i&amp;lt;$width * $height / 100;$i++)<br />
{<br />
$i_x=rand(0,$width);<br />
$i_y=rand(0,$height);<br />
imagesetpixel($image,$i_x,$i_y,imagecolorallocate($image,rand(0,255),rand(0,2550),rand(0,255)));<br />
}<br />
//发送对象<br />
header('content-type:image/png');<br />
imagepng($image);<br />
imagedestroy($image);<br />
?&amp;gt;<br /></pre>
		<br />
		<p>
				<br />
				<br />
				<br />
				<a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454685_1_113ex6.png" target="_blank">
						<img height="74" alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454685_1_113ex6.png" width="447" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" />
				</a>
				<br />
				<br />
				<a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454685_2_46ex6.png" target="_blank">
						<img height="74" alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454685_2_46ex6.png" width="447" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" />
				</a>
				<br />
				<br />
				<a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2454685_3_64ex6.png" target="_blank">
						<img height="74" alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2454685_3_64ex6.png" width="447" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" />
				</a>
				<br />
				<br />
				<br />在线测试: <font color="#ff0000"><b><a href="http://www.phzzy.org/temp/5do8/ex6_login.php" target="_blank">http://www.phzzy.org/temp/5do8/ex6_login.php</a></b></font><br /><br />解释性说明:<br /><br />首先是宽和高,高太小字都看不清楚.随机提取的字符还是那么几个:<br /><br /></p>
		<br />
		<pre class="CodeSamp">$sourcestrings=&amp;quot;0123456789aqwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM&amp;quot;;<br /></pre>
		<br />
		<p>
				<br />
				<br />创建对象,填充成白色:<br /></p>
		<br />
		<pre class="CodeSamp">$image=imagecreate($width,$height);<br />
$white=imagecolorallocate($image,255,255,255);<br />
imagefill($image,0,0,$white);<br /></pre>
		<br />
		<p>
				<br />然后加载您要验证码的字体:<br /></p>
		<br />
		<pre class="CodeSamp">$fonts= dirname(__FILE__);//返回当前根目录,字体文件复制到这里,字体文件是*.ttf文件<br />
putenv('&amp;quot;gdfontpath=&amp;quot;.$fonts=.&amp;quot;&amp;quot;');<br />
$fontname='arial';<br /></pre>
		<br />
		<p>
				<br />定义字符的高度,这里我设置成高度的一半:<br /></p>
		<br />
		<pre class="CodeSamp">$font_size=floor($height / 2);<br /></pre>
		<br />
		<p>
				<br />
				<br />清除变量,随机设置要生成字符的个数:<br /></p>
		<br />
		<pre class="CodeSamp">unset($sessionval);<br />
$strsize=rand(5,8);<br /></pre>
		<br />
		<p>
				<br />
				<br />循环,一个个的把字符打上去:<br /><br /><!--ubbcodetab-->    <!--/ubbcodetab-->得到本次循环的字符串.,并加在变量后面一会儿写入session<br /><!--ubbcodetab-->    <!--/ubbcodetab--></p>
		<br />
		<pre class="CodeSamp">    $i_temp=rand(1,62);<br />
$sessionval .=$sourcestrings[$i_temp];</pre>
		<br />
		<p>
				<br />
				<!--ubbcodetab-->    <!--/ubbcodetab-->得到写入图像的字符串的位置(x和y坐标)<br /><!--ubbcodetab-->    <!--/ubbcodetab--></p>
		<br />
		<pre class="CodeSamp">$x_i =$font_size + $i *$width / ($strsize+1);<br />
$y_i = $height / 2;</pre>
		<br />
		<p>
				<br />
				<!--ubbcodetab-->    <!--/ubbcodetab-->设置倾斜度,是从正面看的,.<!--ubbcodetab-->    <!--/ubbcodetab--><br /><!--ubbcodetab-->    <!--/ubbcodetab--></p>
		<br />
		<pre class="CodeSamp">$angle_i=rand(-120,120);</pre>
		<br />
		<p>
				<br />
				<!--ubbcodetab-->    <!--/ubbcodetab-->随机生成颜色,</p>
		<br />
		<pre class="CodeSamp">$fontcolor_a=imagecolorallocate($image,rand(0,255),rand(0,255),rand(0,255));</pre>
		<br />
		<p>
				<br />
				<!--ubbcodetab-->    <!--/ubbcodetab--><br /><!--ubbcodetab-->    <!--/ubbcodetab-->写入到图像;<br /><!--ubbcodetab-->    <!--/ubbcodetab--></p>
		<br />
		<pre class="CodeSamp">imageTTFText($image,$font_size,$angle_i,$x_i,$y_i,$fontcolor_a,$fontname,$sourcestrings[$i_temp]);</pre>
		<br />
		<p>
				<br />
				<br />
				<!--ubbcodetab-->    <!--/ubbcodetab-->如果对此函数存在疑问,请查阅相关资料.非常容易.<br /><!--ubbcodetab-->    <!--/ubbcodetab--><br />写入到session,一边注册码使用:<br /></p>
		<br />
		<pre class="CodeSamp">unset($_SESSION['cjjer']);<br />
$_SESSION['cjjer'] = $sessionval;<br /></pre>
		<br />
		<p>
				<!--ubbcodetab-->    <!--/ubbcodetab--><br />添加杂点:<br /></p>
		<br />
		<pre class="CodeSamp">//杂点数目<br />
for($i=0;$i&amp;lt;$width * $height / 100;$i++)<br />
{<br />
$i_x=rand(0,$width);<br />
$i_y=rand(0,$height);<br />
imagesetpixel($image,$i_x,$i_y,imagecolorallocate($image,rand(0,255),rand(0,2550),rand(0,255)));<br />
}<br /></pre>
		<br />
		<p>
				<br />输出到头:<br /></p>
		<br />
		<pre class="CodeSamp">header('content-type:image/png');//这行表明是png图像,可不要,默认可以输出的.但不是图像的头格式<br />
imagepng($image);<br />
imagedestroy($image);<br /></pre>
		<br />
		<p>
				<br />
				<br />
				<br />你可以加载你自己的字体库,设置旋转角度$angle_i=rand(-120,120);设置字体高度$font_size=floor($height / 2);字体颜色$fontcolor_a和随机数的个数:$strsize=rand(5,8);<br /></p>
		<br />
		<p> </p>
		<br />
		<p>
				<strong>
						<font color="#ff0000">例六:给图片打上水印,生成缩列图<br /><br /></font>
				</strong>传统的ASP页子打水印和生成缩列图都是比较繁琐的,一般使用到的是其他组件什么的,但是,PHP可以轻松的干这些事情,正如您预料,不到30行的程序搞定这一切,请看这个源程序:<br /></p>
		<br />
		<pre class="CodeSamp">&amp;lt;?php<br />
$source=&amp;quot;my.jpg&amp;quot;;<br />
$zoom=0.5;<br />
$str='我是帅哥,你是MM么?';<br />
$image=imagecreatefromjpeg($source);<br />
$width=imagesx($image);<br />
$height=imagesy($image);<br />
$color_red=imagecolorallocate($image,111,0,0);//红色<br />
$font=dirname(__FILE__). &amp;quot;//simsun.ttc&amp;quot;;<br />
$str=iconv('GB2312','UTF-8',$str);<br />
$fontsize=30;<br />
$angle=25;<br />
$fromx=$width/5;<br />
$fromy=$height/2;<br />
imagettftext($image,$fontsize,$angle,$fromx,$fromy,$color_red,$font,$str);<br />
$width_temp=imagesx($image) * $zoom;<br />
$height_temp=imagesy($image) * $zoom;<br />
$img=imagecreatetruecolor($width_temp,$height_temp);<br />
imagecopyresized ($img,$image,0,0,0,0,$width_temp, $height_temp,$width,$height);<br />
imagedestroy($image);<br />
$file_zoomname=&amp;quot;my_zoom_jpeg.jpg&amp;quot;;<br />
imagejpeg($img,$file_zoomname);<br />
imagedestroy($img);<br />
?&amp;gt;</pre>
		<br />
		<p>
				<br />
				<br />原始图片:<a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2455034_1_my.jpg" target="_blank"><img height="298" alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2455034_1_my.jpg" width="447" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br />生成的jpg图片:<br /><a class="page" href="http://www.blueidea.com/articleimg/upload/2006/2/13/2455034_2_my_zoom_jpeg.jpg" target="_blank"><img alt="click for full size" src="http://www.blueidea.com/articleimg/upload/2006/2/13/2455034_2_my_zoom_jpeg.jpg" onload="javascript:if(this.width&amp;gt;document.body.clientWidth-300) {this.height=(document.body.clientWidth-300)*this.height/this.width;this.width=document.body.clientWidth-300}" border="0" /></a><br /><br />原始图片70K, 这里说下,如果生成gif,文件18k多,而png要用去76k,so我们生成缩列图用jpeg格式.<br /><br />代码分析:<br /><br />这里我先设置了几个参数:<br /></p>
		<br />
		<pre class="CodeSamp">$source=&amp;quot;my.jpg&amp;quot;; //源图片<br />
$zoom=0.5; //缩放百分比<br />
$str='我是帅哥,你是MM么?'; //水印的文字<br /></pre>
		<br />
		<p>
				<br />
				<br />装载源图(不打水印不装载):<br /></p>
		<br />
		<pre class="CodeSamp">$image=imagecreatefromjpeg($source);<br /></pre>
		<br />
		<p>
				<br />获取长,宽的大小:<br /></p>
		<br />
		<pre class="CodeSamp">$width=imagesx($image);<br />
$height=imagesy($image);<br /></pre>
		<br />
		<p>
				<br />
				<font color="#ff0000">
						<b>设置水印字体,因为我们用的是中文,必须导入中文字体库,否则写不上或乱码,然后必须转换字符串编码</b>
				</font>
				<br />
		</p>
		<br />
		<pre class="CodeSamp">$font=dirname(__FILE__). &amp;quot;//simsun.ttc&amp;quot;;<br />
$str=iconv('GB2312','UTF-8',$str);<br /></pre>
		<br />
		<p>
				<br />设置开始点,字体大小,视角:,写上字符串:<br /></p>
		<br />
		<pre class="CodeSamp">$fontsize=30;<br />
$angle=25;<br />
$fromx=$width/5;<br />
$fromy=$height/2;<br />
imagettftext($image,$fontsize,$angle,$fromx,$fromy,$color_red,$font,$str);<br /></pre>
		<br />
		<p>
				<br />
				<br />按照缩放的大小要求生成新大小的对象:<br /></p>
		<br />
		<pre class="CodeSamp">$width_temp=imagesx($image) * $zoom;<br />
$height_temp=imagesy($image) * $zoom;<br />
$img=imagecreatetruecolor($width_temp,$height_temp);<br /></pre>
		<br />
		<p>
				<br />把源图copy到新图,gd库的imagecopyresized自动缩放大小的<br /></p>
		<br />
		<pre class="CodeSamp">imagecopyresized ($img,$image,0,0,0,0,$width_temp, $height_temp,$width,$height);<br /></pre>
		<br />
		<p>
				<br />生成小图片,清除对象:<br /></p>
		<br />
		<pre class="CodeSamp">imagedestroy($image);<br />
$file_zoomname=&amp;quot;my_zoom_jpeg.jpg&amp;quot;;<br />
imagejpeg($img,$file_zoomname);<br />
imagedestroy($img);<br /></pre>
		<br />
		<p>
				<br />
				<br />生成缩洌图,水印大体核心技术就这么点.</p><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6706.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-15 18:14 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/15/6706.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP的COOKIE设置为浏览器进程</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/15/6705.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Mon, 15 Jun 2009 09:15:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/15/6705.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6705.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/15/6705.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6705.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6705.html</trackback:ping><description><![CDATA[<div class="content" id="textbody">
				<p>例如：</p>
				<p>
				</p>
				<table style="BORDER-RIGHT: rgb(204,204,204) 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: rgb(204,204,204) 1px dotted; BORDER-LEFT: rgb(204,204,204) 1px dotted; BORDER-BOTTOM: rgb(204,204,204) 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
						<tbody>
								<tr>
										<td bgcolor="#fdfddf">
												<font color="#ff0000">以下为引用的内容：</font>
												<br />
												<font face="Courier New">&lt;?php<br />$USERID="PHPer";<br />$CookieTime=0;<br />setcookie("USERID", "$USERID", time()+$CookieTime,"/","btcuxiao.com");<br />?&gt;</font>
										</td>
								</tr>
						</tbody>
				</table>
				<p>你会发现这个语句执行过后，Cookie里什么也没有，到下一个页面就显示没有$USERID这个COOKIE变量值。<br />问题分析如下：</p>
				<p>首先，设置浏览器进程的“Cookie 过期的时间”这个值并不是当前Unix时间戳+0，如果设置为浏览器进程的话，直接将过期时间设置为0即可。<br />其次，不清楚你测试这个页面时候使用的域名是什么，如果你设置了“<font face="Courier New">btcuxiao.com</font>”的话，就说明你必须使用“<font face="Courier New">btcuxiao.com</font>”进行访问 cookie才会有效，其实如果你的域名很多访问这个页面的话，那么这个地方可以为空或者访问这个cookie的域名都是一个域下面的，那么就设置为“.<font face="Courier New">btcuxiao.com</font>”，记得前面有“点”</p>
				<p>上面的程序如果你这样写的话，可能会有效： </p>
				<p>
				</p>
				<table style="BORDER-RIGHT: rgb(204,204,204) 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: rgb(204,204,204) 1px dotted; BORDER-LEFT: rgb(204,204,204) 1px dotted; BORDER-BOTTOM: rgb(204,204,204) 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
						<tbody>
								<tr>
										<td bgcolor="#fdfddf">
												<font color="#ff0000">以下为引用的内容：</font>
												<br />
												<font face="Courier New">&lt;?php<br />$USERID="PHPer";<br />$CookieTime=0;<br />setcookie("USERID", "$USERID", 0,"/","");</font>
												<p>
														<font face="Courier New">echo (isset($_COOKIE['USERID']) ? $_COOKIE['USERID'] : '');<br />?&gt;</font>
												</p>
										</td>
								</tr>
						</tbody>
				</table>
				<p>第一次打开这个页面时候是不会有任何输出的，因为cookie并不会在当前页面即刻生效。<br />刷新以后会显示的。 </p>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6705.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-15 17:15 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/15/6705.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP控制输出缓存详解</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/10/6695.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Wed, 10 Jun 2009 08:25:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/10/6695.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6695.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/10/6695.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6695.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6695.html</trackback:ping><description><![CDATA[Output Control 函数可以让你自由控制脚本中数据的输出。它非常地有用，特别是对于：当你想在数据已经输出后，再输出文件头的情况。输出控制函数不对使用 header() 或 setcookie(), 发送的文件头信息产生影响,只对那些类似于 echo() 和 PHP 代码的数据块有作用。 <br /><br />我们先举一个简单的例子，让大家对Output Control有一个大致的印象： <br />Example 1. <br /><p class="php">&lt;?php <br />ob_start(); //打开缓冲区 <br />echo \"Hellon\"; //输出 <br />header(“location:index.php”); //把浏览器重定向到index.php <br />ob_end_flush();//输出全部内容到浏览器 <br />?&gt; </p>所有对header()函数有了解的人都知道，这个函数会发送一段文件头给浏览器，但是如果在使用这个函数之前已经有了任何输出（包括空输出，比如空格，回车和换行）就会提示出错。如果我们去掉第一行的ob_start()，再执行此程序，我们会发现得到了一条错误提示：“Header had all ready send by”！但是加上ob_start，就不会提示出错，原因是当打开了缓冲区，echo后面的字符不会输出到浏览器，而是保留在服务器，直到你使用 flush或者ob_end_flush才会输出，所以并不会有任何文件头输出的错误！ <br /><br /><br />一、 相关函数简介： <br />1、Flush：刷新缓冲区的内容，输出。 <br />函数格式：flush() <br />说明：这个函数经常使用，效率很高。 <br />2、ob_start ：打开输出缓冲区 <br />函数格式：void ob_start(void) <br />说明：当缓冲区激活时，所有来自PHP程序的非文件头信息均不会发送，而是保存在内部缓冲区。为了输出缓冲区的内容，可以使用ob_end_flush()或flush()输出缓冲区的内容。 <br />3 、ob_get_contents ：返回内部缓冲区的内容。 <br />使用方法：string ob_get_contents(void) <br />说明：这个函数会返回当前缓冲区中的内容，如果输出缓冲区没有激活，则返回 FALSE 。 <br />4、ob_get_length：返回内部缓冲区的长度。 <br />使用方法：int ob_get_length(void) <br />说明：这个函数会返回当前缓冲区中的长度；和ob_get_contents一样，如果输出缓冲区没有激活。则返回 FALSE。 <br />5、ob_end_flush ：发送内部缓冲区的内容到浏览器，并且关闭输出缓冲区。 <br />使用方法：void ob_end_flush(void) <br />说明：这个函数发送输出缓冲区的内容（如果有的话）。 <br />6、ob_end_clean：删除内部缓冲区的内容，并且关闭内部缓冲区 <br />使用方法：void ob_end_clean(void) <br />说明：这个函数不会输出内部缓冲区的内容而是把它删除！ <br />7、ob_implicit_flush：打开或关闭绝对刷新 <br />使用方法：void ob_implicit_flush ([int flag]) <br />说明：使用过Perl的人都知道$|=x的意义，这个字符串可以打开/关闭缓冲区，而ob_implicit_flush函数也和那个一样，默认为关闭缓冲区，打开绝对输出后，每个脚本输出都直接发送到浏览器，不再需要调用 flush() <br /><br /><br />二、深入了解： <br /><br />1. 关于Flush函数： <br />这个函数在PHP3中就出现了，是一个效率很高的函数，他有一个非常有用的功能就是刷新browser的cache.我们举一个运行效果非常明显的例子来说明flush. <br />Example 2. <br /><p class="php">&lt;?php <br />for($i = 1; $i &lt;= 300; $i++ ) print(“ “); <br />// 这一句话非常关键，cache的结构使得它的内容只有达到一定的大小才能从浏览器里输出 <br />// 换言之，如果cache的内容不达到一定的大小，它是不会在程序执行完毕前输出的。经 <br />// 过测试，我发现这个大小的底限是256个字符长。这意味着cache以后接收的内容都会 <br />// 源源不断的被发送出去。 <br />For($j = 1; $j &lt;= 20; $j++) { <br />echo $j.” <br />”; <br />flush(); //这一部会使cache新增的内容被挤出去，显示到浏览器上 <br />sleep(1); //让程序“睡”一秒钟，会让你把效果看得更清楚 <br />} <br />?&gt; </p><br />具体效果你可以到这里看看<a href="http://www.phpchina.com/html/82/%5C%22http://www.php2000.com/%7Euchinaboy/out.php%5C%22">http://www.php2000.com/~uchinaboy/out.php</a><br />PHP2000的最新的PHP聊天室就是用的这个技术，可惜的是源代码未公开 L <br />注：如果在程序的首部加入ob_implicit_flush()打开绝对刷新,就可以在程序中不再使用flush(),这样做的好处是：提高效率！ <br /><br />2. 关于ob系列函数： <br />我想先引用我的好朋友y10k的一个例子： <br />Example 3. <br /><p class="php">比如你用得到服务器和客户端的设置信息，但是这个信息会因为客户端的不同而不同，如果想要保存phpinfo()函数的输出怎么办呢？在没有缓冲区控制之前，可以说一点办法也没有，但是有了缓冲区的控制，我们可以轻松的解决： <br />&lt;?php <br />ob_start(); //打开缓冲区 <br />phpinfo(); //使用phpinfo函数 <br />$info=ob_get_contents(); //得到缓冲区的内容并且赋值给$info <br />$file=fopen(\'info.txt\',\'w\'); //打开文件info.txt <br />fwrite($file,$info); //写入信息到info.txt <br />fclose($file); //关闭文件info.txt <br />?&gt; </p><br />用以上的方法，就可以把不同用户的phpinfo信息保存下来，这在以前恐怕没有办法办到！其实上面就是将一些“过程”转化为“函数”的方法！ <br />或许有人会问：“难道就这个样子吗？还有没有其他用途？”当然有了，比如笔者论坛的PHP 语法加亮显示就和这个有关（PHP默认的语法加亮显示函数会直接输出，不能保存结果，如果在每次调用都显示恐怕会很浪费CPU，笔者的论坛就把语法加亮函数显示的结果用控制缓冲区的方法保留了），大家如果感兴趣的话可以来看看http://www.zphp.com/bbs/！ <br /><br />可能现在大家对ob_start()的功能有了一定的了解，上面的一个例子看似简单，但实际上已经掌握了使用ob_start()的要点。 <br />&lt;1&gt;.使用ob_start打开browser的cache，这样可以保证cache的内容在你调用flush(),ob_end_flush()（或程序执行完毕）之前不会被输出。 <br />&lt;2&gt;.现在的你应该知道你所拥有的优势：可以在任何输出内容后面使用header,setcookie以及session，这是 ob_start一个很大的特点；也可以使用ob_start的参数，在cache被写入后，然后自动运行命令，比如 ob_start(\"ob_gzhandler\")；而我们最常用的做法是用ob_get_contents()得到cache中的内容，然后再进行处理…… <br />&lt;3&gt;.当处理完毕后，我们可以使用各种方法输出，flush(),ob_end_flush(),以及等到程序执行完毕后的自动输出。当然，如果你用的是ob_get_contents()，那么就要你自己控制输出方式了。 <br /><br />来，让我们看看能用ob系列函数做些什么…… <br /><br />一、 静态模版技术 <br /><br />简介：所谓静态模版技术就是通过某种方式，使得用户在client端得到的是由PHP产生的html页面。如果这个html页面不会再被更新，那么当另外的用户再次浏览此页面时，程序将不会再调用PHP以及相关的数据库，对于某些信息量比较大的网站，例如sina,163,sohu。类似这种的技术带来的好处是非常巨大的。 <br /><br />我所知道的实现静态输出的有两种办法： <br />&lt;1&gt;.通过y10k修改的phplib的一个叫template.inc.php类实现。 <br />&lt;2&gt;.使用ob系列函数实现。 <br />对于第一种方法，因为不是这篇文章所要研究的问题，所以不再赘述。 <br />我们现在来看一看第二种方法的具体实现： <br />Example 4. <br /><br /><p class="php">&lt;?php <br />ob_start();//打开缓冲区 <br />?&gt; <br />php页面的全部输出 <br />&lt;? <br />$content = ob_get_contents();//取得php页面输出的全部内容 <br />$fp = fopen(“output00001.html”, “w”); //创建一个文件，并打开，准备写入 <br />fwrite($fp, $content); //把php页面的内容全部写入output00001.html，然后…… <br />fclose($fp); <br />?&gt; </p>这样，所谓的静态模版就很容易的被实现了…… <br /><br />二、 捕捉输出 <br /><br />以上的Example 4.是一种最简单的情况，你还可以在写入前对$content进行操作…… <br />你可以设法捕捉一些关键字，然后去对它进行再处理，比如Example 3.所述的PHP语法高亮显示。个人认为，这个功能是此函数最大的精华所在，它可以解决各种各样的问题，但需要你有足够的想象力…… <br />Example 5. <br /><p class="php">&lt;? <br />Function run_code($code) { <br />If($code) { <br />ob_start(); <br />eval($code); <br />$contents = ob_get_contents(); <br />ob_end_clean(); <br />}else { <br />echo “错误！没有输出”; <br />exit(); <br />} <br />return $contents; <br />} </p><br />以上这个例子的用途不是很大，不过很典型$code的本身就是一个含有变量的输出页面，而这个例子用eval把$code中的变量替换，然后对输出结果再进行输出捕捉，再一次的进行处理…… <br /><br />Example 6. 加快传输 <br /><br /><p class="php">&lt;? <br />/* <br />** Title.........: PHP4 HTTP Compression Speeds up the Web <br />** Version.......: 1.20 <br />** Author........: catoc &lt;catoc@163.net&gt; <br />** Filename......: gzdoc.php <br />** Last changed..: 18/10/2000 <br />** Requirments...: PHP4 &gt;= 4.0.1 <br />** PHP was configured with --with-zlib[=DIR] <br />** Notes.........: Dynamic Content Acceleration compresses <br />** the data transmission data on the fly <br />** code by sun jin hu (catoc) &lt;catoc@163.net&gt; <br />** Most newer browsers since 1998/1999 have <br />** been equipped to support the HTTP 1.1 <br />** standard known as \"content-encoding.\" <br />** Essentially the browser indicates to the <br />** server that it can accept \"content encoding\" <br />** and if the server is capable it will then <br />** compress the data and transmit it. The <br />** browser decompresses it and then renders <br />** the page. <br />** <br />** Modified by John Lim (jlim@natsoft.com.my) <br />** based on ideas by Sandy McArthur, Jr <br />** Usage........: <br />** No space before the beginning of the first \'&lt;?\' tag. <br />** ------------Start of file---------- <br />** |&lt;? <br />** | include(\'gzdoc.php\'); <br />** |? &gt; <br />** |&lt;HTML&gt; <br />** |... the page ... <br />** |&lt;/HTML&gt; <br />** |&lt;? <br />** | gzdocout(); <br />** |? &gt; <br />** -------------End of file----------- <br />*/ <br />ob_start(); <br />ob_implicit_flush(0); <br />function CheckCanGzip(){ <br />global $HTTP_ACCEPT_ENCODING; <br />if (headers_sent() || connection_timeout() || connection_aborted()){ <br />return 0; <br />} <br />if (strpos($HTTP_ACCEPT_ENCODING, \'x-gzip\') !== false) return \"x-gzip\"; <br />if (strpos($HTTP_ACCEPT_ENCODING,\'gzip\') !== false) return \"gzip\"; <br />return 0; <br />} <br />/* $level = compression level 0-9, 0=none, 9=max */ <br />function GzDocOut($level=1,$debug=0){ <br />$ENCODING = CheckCanGzip(); <br />if ($ENCODING){ <br />print \"n&lt;!-- Use compress $ENCODING --&gt;n\"; <br />$Contents = ob_get_contents(); <br />ob_end_clean(); <br />if ($debug){ <br />$s = \"&lt;p&gt;Not compress length: \".strlen($Contents); <br />$s .= \" <br />Compressed length: \".strlen(gzcompress($Contents,$level)); <br />$Contents .= $s; <br />} <br />header(\"Content-Encoding: $ENCODING\"); <br />print \"x1fx8bx08x00x00x00x00x00\"; <br />$Size = strlen($Contents); <br />$Crc = crc32($Contents); <br />$Contents = gzcompress($Contents,$level); <br />$Contents = substr($Contents, 0, strlen($Contents) - 4); <br />print $Contents; <br />print pack(\'V\',$Crc); <br />print pack(\'V\',$Size); <br />exit; <br />}else{ <br />ob_end_flush(); <br />exit; <br />} <br />} <br />?&gt; </p>这是catoc的一段很早以前的代码，是在weblogs.com看到的，他利用了zlib的函数，对传输的内容进行了压缩，测试表明，对于10k以上的页面，会产生效果，而且页面越大，效果越明显……<img src ="http://www.phpweblog.net/fuyongjie/aggbug/6695.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-10 16:25 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/10/6695.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ie6下动态缩略图不显示的原因</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/10/6694.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Wed, 10 Jun 2009 08:06:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/10/6694.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6694.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/10/6694.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6694.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6694.html</trackback:ping><description><![CDATA[<p>我在上传生成缩略图时，缩略图显示的链接如下；</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">img </span>
				<span style="COLOR: #ff0000">src</span>
				<span style="COLOR: #0000ff">="/index.php?action=sys_upload_showThumb&amp;id=bdc3955470adfb5637a0d1f517eb3d35"</span>
				<span style="COLOR: #0000ff">/&gt;</span>
		</div>
		<br />结果在ie6下不显示该缩略图；后来追溯到下面一段代码：<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #008080">header</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-type: image/jpeg</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">) ;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #008080">header</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-Length: </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #008080">strlen</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_SESSION</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">fileInfo</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">][</span><span style="COLOR: #800080">$image_id</span><span style="COLOR: #000000">]));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$_SESSION</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">fileInfo</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">][</span><span style="COLOR: #800080">$image_id</span><span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">unset</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_SESSION</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">fileInfo</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">][</span><span style="COLOR: #800080">$image_id</span><span style="COLOR: #000000">]);</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    </span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">exit</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);</span></div><br />于是就想是不是还来不及显示就被unset了？于是删掉就成功了。后来改为了如下代码：<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #008080">header</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-type: image/jpeg</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">) ;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #008080">header</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-Length: </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #008080">strlen</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_SESSION</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">fileInfo</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">][</span><span style="COLOR: #800080">$image_id</span><span style="COLOR: #000000">]));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$_SESSION</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">fileInfo</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">][</span><span style="COLOR: #800080">$image_id</span><span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #008000">/*</span><span style="COLOR: #008000">* 马上输出 上边的session，解决ie6下生成的缩略图在还没有显示前已经被下边的unset($_SESSION['<img src="http://www.phpweblog.net/images/dot.gif" />'])清空，结果致使ie6无法显示缩略图的情况 </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$str</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">.</span><span style="COLOR: #000000"> </span><span style="COLOR: #008080">str_repeat</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">256</span><span style="COLOR: #000000">); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">有些浏览器必须要在输出达到256个字符时才肯输出      </span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">    </span><span style="COLOR: #008080">ob_flush</span><span style="COLOR: #000000">();      <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #008080">flush</span><span style="COLOR: #000000">();  </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 这两个必须要一块用  </span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">unset</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_SESSION</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">fileInfo</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">][</span><span style="COLOR: #800080">$image_id</span><span style="COLOR: #000000">]);</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    </span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">exit</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);</span></div><br />其实这又引出了服务器的输出控制和浏览器的缓存问题，这有点复杂了，以后有机会再研究了。<br /><br /><h1><a title="BT促销网" href="http://www.btcuxiao.com" target="_blank">BT促销网:(http:www.btcuxiao.com)</a></h1><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6694.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-10 16:06 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/10/6694.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php中session的处理机制</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/09/6687.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Tue, 09 Jun 2009 06:10:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/09/6687.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6687.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/09/6687.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6687.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6687.html</trackback:ping><description><![CDATA[<div class="cnt" id="blog_text">
				<p>1。<br />      PHP服务端默认的session存储是文件存放方式，在Windows上PHP默认的Session服务端文件存放在C:\WINDOWS\Temp下，可用session_save_path ('./t/');指定具体存放目录。</p>
				<p>2。<br />      SESSION 的实现中采用COOKIE技术，SESSION会在客户端保存一个包含session_id(SESSION编号)的COOKIE；在服务器端保存其他 session变量，比如session_name等等。当用户请求服务器时也把session_id一起发送到服务器，通过session_id提取所保存在服务器端的变量，就能识别用户是谁了。同时也不难理解为什么SESSION有时会失效了。<br />     当客户端禁用COOKIE时(点击IE中的“工具”—“Internet选项”，在弹出的对话框里点击“安全”—“自定义级别”项，将“允许每个对话 COOKIE”设为禁用)，session_id将无法传递，此时SESSION失效。<font color="#ff3399"><font color="#ff3300">不过php5在linux/unix平台可以自动检查cookie 状态，如果客户端设置了禁用，则系统自动把session_id附加到url上传递。windows主机则无此功能</font>。</font></p>
				<p>3。<br />Session_start() ：开始一个会话或者返回已经存在的会话。<br />在使用Session_start()之前浏览器不能有任何输出，否则会发生以下错误。<br />你可以在php.ini里启动session.auto_start=1，这样就无需每次使用session之前都要调用session_start()。</p>
				<p>4。<br /><font color="#ff3300">如果在session.auto_start=1，会让session_save_path ('./t/');变的无效。因为后一条语句须放前面。</font></p>
				<p>5。<br /><font color="#ff3366">保存在服务器上的session文件，没有遇到session_destroy();，不会被删除。</font><br />即使客户端浏览器已关闭。<br />不过服务器端每次产生的session文件都能保证session文件名的随机性和唯一性。</p>
				<p>6。<a href="http://www.toplee.com/blog/300.html">http://www.toplee.com/blog/300.html</a></p>
				<p>增加PHP的Session存储和处理能力</p>
				<p>可能很多PHPer都用到了PHP提供的Session功能，可以方便的进行会话功能处理，PHP服务端默认的session存储是文件存放方式，在Windows上PHP默认的Session服务端文件存放在C:\WINDOWS\Temp下，*NIX下默认存放在/tmp下，如果说并发访问很大或者session建立太多，在这两个目录下就会存在大量类似sess_xxxxxx的session文件，同一个目录下文件数过多会导致性能下降，并且可能导致受到攻击最终出现文件系统错误。针对这样的情况，PHP本身体提供了比较好的解决办法。<br />　　不少朋友可能都没有注意到php.ini里面Session设置部分中有这样一项：<br />;     session.save_path = "N;MODE;/path"</p>
				<p>
						<br />　　这项设置提供给我们可以给session存放目录进行多级散列，其中“N”表示要设置的目录级数，“MODE”表示目录的权限属性，默认为600，在 WINDOWS上基本是不用设置的，*NIX上也可以不用设置，后面的“/path”表示session文件存放的根目录路径，比如我们设置为下面的格式<br />session.save_path = "2;/tmp/phpsession"</p>
				<p>　　上面的设置表示我们把/tmp/phpsession目录作为php的session文件存放根目录，在该目录下进行两级目录散列，每一级目录分别是0-9和a-z共36个字母数字为目录名，这样存放session的目录可以达到36*36个，相信作为单台服务器来说，这是完全够用了，如果说您的系统架构设计为多台服务器共享session数据，可以把目录级增加到3级或者更多。<br />　　需要注意的是，php自己并不会自动创建子目录，需要您自己动手去创建，网上找到这样的自动创建目录的代码，大家可以做个参考。下面的代码自动创建3级子目录，可以自己动手根据需要进行修改。<br />&lt;?php<br />set_time_limit(0);<br />$string = '0123456789abcdefghijklmnopqrstuvwxyz';<br />$length = strlen($string);<br />function makeDir($param)<br />{<br />    if(!file_exists($param)) {<br />        makeDir(dirname($param));<br />        mkdir($param);<br />    }<br />}<br />for($i = 0; $i &lt; $length; $i++) {<br />    for($j = 0; $j &lt; $length; $j++) {<br />        for($k = 0; $k &lt; $length; $k++) {<br />            makeDir($string[$i].'/'.$string[$j].'/'.$string[$k]);<br />        }<br />    }<br />}<br />?&gt;</p>
				<p>　　大家可能注意到前面的文字中提到了有关多服务器共享php的SESSION，这是很多应用都会遇到的问题，网上也有不少相关的资源，大家可以去google一下，Michael这里只提一下大概的思路。<br />　　一般来说我们用到最多的方法有两种：<br />　　1、NFS或者Samba共享的方法，让各个服务器上存放session文件的磁盘共享，这种方法简单可行。<br />　　2、集中存储到数据库中，这是比较多的实现方法，通过php提供的session_set_save_handler()函数来重定义session函数，推荐使用这种方法。</p>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6687.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-09 14:10 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/09/6687.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>通过负边距实现tab导航菜单</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/08/6683.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Mon, 08 Jun 2009 00:36:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/08/6683.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6683.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/08/6683.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6683.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6683.html</trackback:ping><description><![CDATA[负边距(negative margin)在页面制作过程中，有许多妙用，用的好了能让原本复杂的问题变的简单，本文是针对负边距相关问题的整理，欢迎各位补充。<br /><br /><br />负边距的使用非常简单：<br /><br /><span class="code_title">CSS:</span><div class="code_container"><pre class="css"><ol><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1">&lt;style type=<span class="st0">"text/css"</span>&gt; </div></li><li class="li1"><div class="de1"><span class="coMULTI">/* </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">说明：负边距(negative margin)的相关问题整理  </span></div></li><li class="li2"><div class="de2"><span class="coMULTI">整理：CodeBit.cn （ http://www.codebit.cn ） </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">*/</span></div></li><li class="li1"><div class="de1"><span class="re1">.one </span><span class="br0">{</span></div></li><li class="li1"><div class="de1"><span class="kw1">height</span>:100px; </div></li><li class="li1"><div class="de1"><span class="kw1">width</span>:300px; </div></li><li class="li2"><div class="de2">    border<span class="re2">:2px </span>solid <span class="kw2">red</span>; </div></li><li class="li1"><div class="de1"><span class="kw1">margin-bottom</span>:-10px; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="re1">.two </span><span class="br0">{</span></div></li><li class="li1"><div class="de1"><span class="kw1">height</span>:100px; </div></li><li class="li2"><div class="de2"><span class="kw1">width</span>:300px; </div></li><li class="li1"><div class="de1">    border<span class="re2">:2px </span>solid <span class="kw1">blue</span>; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1">&lt;/style&gt; </div></li><li class="li1"><div class="de1"> </div></li></ol></pre></div><br /><br /><span class="code_title">HTML:</span><div class="code_container"><pre class="html4strict"><ol><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="sc2"><span class="kw2">&lt;p</span><span class="kw3">class</span>=<span class="st0">"one"</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;/p&gt;</span></span></div></li><li class="li1"><div class="de1"><span class="sc2"><span class="kw2">&lt;p</span><span class="kw3">class</span>=<span class="st0">"two"</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;/p&gt;</span></span></div></li><li class="li1"><div class="de1"> </div></li></ol></pre></div><br /><br /><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" alt="" src="http://www.codebit.cn/pub/html/xhtml_css/tip/negative_margin/demo01.gif" /><br /><br /><br />这时，我们会看到蓝色的框伸到了红色框的里面，下面总结一些问题：<br /><br /><h3>如何改变覆盖顺序</h3><br />在本例中，就是如何让红色框覆盖蓝色框，很简单，在需要覆盖到上面的元素样式中添加 ： position:relative;  在本例中，就是要在红色的样式 .one 中添加。<br /><br /><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" alt="" src="http://www.codebit.cn/pub/html/xhtml_css/tip/negative_margin/demo02.gif" /><br /><br /><h3>负边距可以用在哪些地方：</h3><br /><b>导航高亮效果的实现：</b><br /><br /><span class="code_title">CSS:</span><div class="code_container"><pre class="css"><ol><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1">&lt;style type=<span class="st0">"text/css"</span>&gt; </div></li><li class="li1"><div class="de1"><span class="coMULTI">/* </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">说明：负边距(negative margin)的相关问题整理  </span></div></li><li class="li2"><div class="de2"><span class="coMULTI">整理：CodeBit.cn （ http://www.codebit.cn ） </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">*/</span></div></li><li class="li1"><div class="de1">.nav, <span class="re1">.nav </span>li <span class="br0">{</span></div></li><li class="li1"><div class="de1"><span class="kw1">list-style</span>:<span class="kw2">none</span>; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li2"><div class="de2"><span class="re1">.nav </span>li <span class="br0">{</span></div></li><li class="li1"><div class="de1">    border<span class="re2">:2px </span>solid #<span class="nu0">000</span>; </div></li><li class="li1"><div class="de1"><span class="kw1">float</span>:<span class="kw1">left</span>; </div></li><li class="li1"><div class="de1"><span class="kw1">margin-left</span>:10px; </div></li><li class="li1"><div class="de1"><span class="kw1">background</span>:#<span class="nu0">333</span>; </div></li><li class="li2"><div class="de2">    padding<span class="re2">:3px </span>20px; </div></li><li class="li1"><div class="de1"><span class="kw1">margin-bottom</span>:-2px; <span class="coMULTI">/* 遮盖下面内容的边框部分 */</span></div></li><li class="li1"><div class="de1"><span class="kw1">position</span>:<span class="kw2">relative</span>; <span class="coMULTI">/* IE 下要添加此行 */</span></div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="re1">.nav </span>a <span class="br0">{</span></div></li><li class="li2"><div class="de2"><span class="kw1">color</span>:#fff;  </div></li><li class="li1"><div class="de1"><span class="kw1">text-decoration</span>:<span class="kw2">none</span>; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="re1">.nav </span>li<span class="re1">.current </span><span class="br0">{</span></div></li><li class="li1"><div class="de1">    border-bottom<span class="re2">:2px </span>solid #eee; <span class="coMULTI">/* 当前的把下边框的颜色换成和下边内容相同的 */</span></div></li><li class="li2"><div class="de2"><span class="kw1">background</span>:#eee; <span class="coMULTI">/* 背景的颜色也换成相同的 */</span></div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="re1">.nav </span>li<span class="re1">.current </span>a <span class="br0">{</span><span class="kw1">color</span>:#<span class="nu0">000</span>;<span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="re1">.<span class="kw1">content</span></span><span class="br0">{</span></div></li><li class="li1"><div class="de1">    border<span class="re2">:2px </span>solid #<span class="nu0">000</span>; </div></li><li class="li2"><div class="de2"><span class="kw1">background</span>:#eee; </div></li><li class="li1"><div class="de1"><span class="kw1">height</span>:100px; </div></li><li class="li1"><div class="de1"><span class="kw1">width</span>:300px; </div></li><li class="li1"><div class="de1"><span class="kw1">clear</span>:<span class="kw2">both</span>; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li2"><div class="de2">&lt;/style&gt; </div></li><li class="li1"><div class="de1"> </div></li></ol></pre></div><br /><br /><span class="code_title">HTML:</span><div class="code_container"><pre class="html4strict"><ol><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="sc2"><span class="kw2">&lt;ul</span><span class="kw3">class</span>=<span class="st0">"nav"</span><span class="kw2">&gt;</span></span></div></li><li class="li1"><div class="de1"><span class="sc2"><span class="kw2">&lt;li</span><span class="kw3">class</span>=<span class="st0">"current"</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;a</span><span class="kw3">href</span>=<span class="st0">""</span><span class="kw2">&gt;</span></span>当前<span class="sc2"><span class="kw2">&lt;/a&gt;</span></span><span class="sc2"><span class="kw2">&lt;/li&gt;</span></span></div></li><li class="li1"><div class="de1"><span class="sc2"><span class="kw2">&lt;li&gt;</span></span><span class="sc2"><span class="kw2">&lt;a</span><span class="kw3">href</span>=<span class="st0">""</span><span class="kw2">&gt;</span></span>导航<span class="sc2"><span class="kw2">&lt;/a&gt;</span></span><span class="sc2"><span class="kw2">&lt;/li&gt;</span></span></div></li><li class="li2"><div class="de2"><span class="sc2"><span class="kw2">&lt;li&gt;</span></span><span class="sc2"><span class="kw2">&lt;a</span><span class="kw3">href</span>=<span class="st0">""</span><span class="kw2">&gt;</span></span>导航<span class="sc2"><span class="kw2">&lt;/a&gt;</span></span><span class="sc2"><span class="kw2">&lt;/li&gt;</span></span></div></li><li class="li1"><div class="de1"><span class="sc2"><span class="kw2">&lt;/ul&gt;</span></span></div></li><li class="li1"><div class="de1"><span class="sc2"><span class="kw2">&lt;div</span><span class="kw3">class</span>=<span class="st0">"content"</span><span class="kw2">&gt;</span></span></div></li><li class="li1"><div class="de1"><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span></div></li><li class="li1"><div class="de1"> </div></li></ol></pre></div><br /><br />结果：<br /><br /><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" alt="" src="http://www.codebit.cn/pub/html/xhtml_css/tip/negative_margin/demo03.gif" /><br /><br />注意：firefox 下面 .nav li 不用加 position:relative; 也能覆盖到下面的 div ，但是 ie 下面要加上。<br /><br /><b>修正 IE 的 bug</b><br /><br />相信大家都很了解 IE 的 3 像素 bug，当浮动元素和非浮动元素相邻时，会增加额外的 3 像素，这个时候，我们就可以用负边距来解决（并非唯一的办法）：<br /><br /><span class="code_title">CSS:</span><div class="code_container"><pre class="css"><ol><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1">&lt;style type=<span class="st0">"text/css"</span>&gt; </div></li><li class="li1"><div class="de1"><span class="coMULTI">/* </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">说明：负边距(negative margin)的相关问题整理  </span></div></li><li class="li2"><div class="de2"><span class="coMULTI">整理：CodeBit.cn （ http://www.codebit.cn ） </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">*/</span></div></li><li class="li1"><div class="de1"><span class="re0">#floatContent <span class="br0">{</span></span></div></li><li class="li1"><div class="de1"><span class="kw1">float</span>: <span class="kw1">left</span>; </div></li><li class="li1"><div class="de1"><span class="kw1">width</span>: 300px; </div></li><li class="li2"><div class="de2"><span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="re0">#otherContent <span class="br0">{</span></span></div></li><li class="li1"><div class="de1"><span class="kw1">margin-left</span>: 300px; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">/* 对 MacIE 隐藏 \*/</span></div></li><li class="li2"><div class="de2">* html <span class="re0">#floatContent <span class="br0">{</span></span></div></li><li class="li1"><div class="de1"><span class="kw1">margin-right</span>: -3px; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1">* html <span class="re0">#otherContent <span class="br0">{</span></span></div></li><li class="li1"><div class="de1"><span class="kw1">height</span>: <span class="nu0">1</span>%; <span class="coMULTI">/* 如果你没有设置 #otherContent 的高度或者宽度 */</span></div></li><li class="li2"><div class="de2"><span class="kw1">margin-left</span>: <span class="nu0">0</span>; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">/* 隐藏结束 */</span></div></li><li class="li1"><div class="de1">&lt;/style&gt; </div></li><li class="li1"><div class="de1"> </div></li></ol></pre></div><br /><br />这里只是列举了部分和负边距相关的问题，欢迎各位修正、完善。<img src ="http://www.phpweblog.net/fuyongjie/aggbug/6683.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-08 08:36 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/08/6683.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>对文件大小的格式化（有bytes输出KB，MB等等）</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/05/6680.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Fri, 05 Jun 2009 06:37:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/05/6680.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6680.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/05/6680.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6680.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6680.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> setupSize(</span>
				<span style="COLOR: #800080">$fileSize</span>
				<span style="COLOR: #000000">) {    <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$size</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">sprintf</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">%u</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$fileSize</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$sizename</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">array</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> Bytes</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> KB</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> MB</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> GB</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> TB</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> PB</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> EB</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> ZB</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> YB</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);    <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">round</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$size</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #008080">pow</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">1024</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">floor</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">log</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$size</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1024</span>
				<span style="COLOR: #000000">))))</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> 3</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$sizename</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> setupSize(</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">200000</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6680.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-05 14:37 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/05/6680.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>将bmp图片转为jpg等其他任意格式的图片</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/03/6675.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Wed, 03 Jun 2009 09:49:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/03/6675.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6675.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/03/6675.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6675.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6675.html</trackback:ping><description><![CDATA[<br />
		<br />
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">例子：</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #800080">$path</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> ROOT </span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">upload/2009/06/03/124401282315771.</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$pathAll</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$path</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bmp</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$mi</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">''</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$mi</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> ImageCreateFromBMP(</span>
				<span style="COLOR: #800080">$pathAll</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />imagejpeg(</span>
				<span style="COLOR: #800080">$mi</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$path</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">jpg</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">函数如下：</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> ImageCreateFromBMP(</span>
				<span style="COLOR: #800080">$filename</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">Ouverture du fichier en mode binaire</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #000000">!</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$f1</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">fopen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$filename</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">rb</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">FALSE</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">1 : Chargement des ent�tes FICHIER</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #800080">$FILE</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">unpack</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">vfile_type/Vfile_size/Vreserved/Vbitmap_offset</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">fread</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$f1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">14</span>
				<span style="COLOR: #000000">));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$FILE</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">file_type</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">!=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">19778</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">FALSE</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">2 : Chargement des ent�tes BMP</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">unpack</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                 </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">/Vcompression/Vsize_bitmap/Vhoriz_resolution</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                 </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">/Vvert_resolution/Vcolors_used/Vcolors_important</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">fread</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$f1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">40</span>
				<span style="COLOR: #000000">));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">colors</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">pow</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bits_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">size_bitmap</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">size_bitmap</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$FILE</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">file_size</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$FILE</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bitmap_offset</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bytes_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bits_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bytes_per_pixel2</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">ceil</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bytes_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">decal</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">width</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bytes_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">decal</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">-=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">floor</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">width</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bytes_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">decal</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">decal</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">decal</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">decal</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">3 : Chargement des couleurs de la palette</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #800080">$PALETTE</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">array</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">colors</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">16777216</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$PALETTE</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">unpack</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">V</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">colors</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">fread</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$f1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">colors</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">4 : Cr�ation de l'image</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #800080">$IMG</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">fread</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$f1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">size_bitmap</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$VIDE</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">chr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$res</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> imagecreatetruecolor(</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">width</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">height</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$Y</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">height</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$Y</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$X</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$X</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">width</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">])<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bits_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">24</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">unpack</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">V</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$IMG</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">3</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #800080">$VIDE</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bits_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">16</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     { <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">unpack</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$IMG</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$PALETTE</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bits_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     { <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">unpack</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$VIDE</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$IMG</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$PALETTE</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bits_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">unpack</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$VIDE</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$IMG</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">floor</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">) ; </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0x0F</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$PALETTE</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bits_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">unpack</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$VIDE</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$IMG</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">floor</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">     ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">]        </span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000">7</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0x40</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000">6</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0x20</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">3</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0x10</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0x8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000">3</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0x4</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">6</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0x2</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000"> ((</span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">7</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0x1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$PALETTE</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">FALSE</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     imagesetpixel(</span>
				<span style="COLOR: #800080">$res</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$X</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$Y</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$COLOR</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">]);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #800080">$X</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">+=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">bytes_per_pixel</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$Y</span>
				<span style="COLOR: #000000">--</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$P</span>
				<span style="COLOR: #000000">+=</span>
				<span style="COLOR: #800080">$BMP</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">decal</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />   }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">Fermeture du fichier</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #008080">fclose</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$f1</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$res</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6675.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-03 17:49 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/03/6675.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php 数组数据结构处理</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/06/02/6670.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Tue, 02 Jun 2009 07:46:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/06/02/6670.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6670.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/06/02/6670.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6670.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6670.html</trackback:ping><description><![CDATA[1.<br />【案例】如下数组，要将最底层的数组为空的去掉<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">Array</span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />(<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    [tech] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">Array</span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        (<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            [Article] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">Array</span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                (<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    [</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> AdminForm<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    [</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> AdminSave<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    [</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> AdminList<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    [</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> AdminMultiDeal<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                )<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            [VoteOption] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />           <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    [www] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">Array</span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        (<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            [Home] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        )<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />)</span></div>转为：<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">Array</span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />(<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    [tech] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">Array</span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        (<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            [Article] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">Array</span><span style="COLOR: #000000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                (<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    [</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> AdminForm<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    [</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> AdminSave<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    [</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> AdminList<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    [</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> AdminMultiDeal<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                )<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />)</span></div><br />【思路：】<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">foreach</span><span style="COLOR: #000000"> (</span><span style="COLOR: #800080">$mca</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$k1</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$v1</span><span style="COLOR: #000000">) {            <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">foreach</span><span style="COLOR: #000000"> (</span><span style="COLOR: #800080">$v1</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$k2</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">=&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$v2</span><span style="COLOR: #000000">) {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #0000ff">empty</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$v2</span><span style="COLOR: #000000">)) {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span><span style="COLOR: #800080">$newMca</span><span style="COLOR: #000000">[</span><span style="COLOR: #800080">$k1</span><span style="COLOR: #000000">][</span><span style="COLOR: #800080">$k2</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$v2</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">只得到具有admin的action的MCA</span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">                </span><span style="COLOR: #000000"> }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        }</span></div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6670.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-06-02 15:46 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/06/02/6670.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php if 判读时要注意的几个小问题</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/05/22/6490.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Fri, 22 May 2009 00:45:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/05/22/6490.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6490.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/05/22/6490.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6490.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6490.html</trackback:ping><description><![CDATA[1.<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #800080">$k</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">com</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> <font style="BACKGROUND-COLOR: #009900">(</font></span><font style="BACKGROUND-COLOR: #009900"><span style="COLOR: #800080">$k</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span></font><span style="COLOR: #000000">) { </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">有时候在循环数组时，如果既有关联数组又有数字索引数组，就可能出现这中不科学的用法</span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">这里会输出0</span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">} </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}</span></div>2.<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #800080">$arr</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">array</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">content</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><font style="BACKGROUND-COLOR: #ffff33"><span style="COLOR: #008080">in_array</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$arr</span></font><span style="COLOR: #000000">)) {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">yes ,in the array</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">将运行这句</span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">} </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">no ,<img src="http://www.phpweblog.net/images/dot.gif" />..</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}</span></div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6490.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-05-22 08:45 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/05/22/6490.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【隔行换色，鼠标移入高亮】</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/05/20/6489.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Wed, 20 May 2009 07:09:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/05/20/6489.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6489.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/05/20/6489.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6489.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6489.html</trackback:ping><description><![CDATA[<p>需要将table的id为mytable<br /><br />&lt;style type="text/css"&gt;<br />tr.even td{background:#eee;}<br />tr.over td{background:#999}<br />#mytable tr {<br /> background-color: #fff;<br />}<br />&lt;/style&gt;<br />&lt;script type="text/javascript"&gt;<br />$(document).ready(function(){<br /> $("#mytable tr").mouseover(function() {<br />   $(this).addClass("over");<br />  }).mouseout(function() {<br />   $(this).removeClass("over");<br />  });<br /> $("#mytable tr:even").addClass("even");<br />});<br /> <br />&lt;/script&gt;</p><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-05-20 15:09 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/05/20/6489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用PHP读取excel（转）</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/05/19/6486.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Tue, 19 May 2009 02:50:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/05/19/6486.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6486.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/05/19/6486.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6486.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6486.html</trackback:ping><description><![CDATA[在 PHP 中有提供 fgetcsv 和 fputcsv 让我们读取 CSV 格式的档案，先将 Excel 档案另存为 .csv 的格式，再使用前面两个函数来读取或输出档案，反正 .csv Excel 也可以打开。 <br />　　不过，.csv 中只能存一个工作表，这个应该是一个缺陷。最近正在着手写一个程序，它必须要能读取使用者上传的 Excel 档案中的数据， google 了一下，原来已经有人写了一个叫 phpExcelReader 的 class，可以让我们很方便的读取任一个工作表。它的网址如下：<br /><br /><a href="http://sourceforge.net/projects/phpexcelreader/" target="_blank">http://sourceforge.net/projects/phpexcelreader/</a><br />或者<br /><a href="http://d.download.csdn.net/source/412364" target="_blank">http://d.download.csdn.net/source/412364</a><br /><br />该 class 使用的方法可以参考网站下载回来的压缩档中的 example.php。<br /><br />不过我下载回来的 (版本 2007-07-05 19:57)，有两点要注意：<br /><br />reader.php 中的下面这行要修改<br />将 require_once 'Spreadsheet/Excel/Reader/OLERead.php';<br />改为 require_once 'oleread.inc';<br /><br />example.php 中<br />修改 $data-&gt;setOutputEncoding('CP1251');<br />为 $data-&gt;setOutputEncoding('CP936');<br />不然中文会有问题。<br />繁体的话可以修改为CP950、日文是CP932，具体可参考codepage说明。<br />修改 $data-&gt;read('jxlrwtest.xls');<br />为自己的 excel 文件名，zip 档中附的 jxlrwtest.xls 应该是坏了。<br />用了一下，还满不错的！解决了我一个大难题。<br /><br />若中文输出还是有问题可以参考以下信息（来自互联网）：<br /><br />试着在不同机器上测试，同一个程序，却发现有一台机器的输出有问题，Excel 中的所有中文字都没读出来。由于 Excel 的中文是以 'UTF-16LE' 的编码储存，所以 phpExcelReader 是利用 php 中的 iconv 来转码，而那台机器的 libiconv 版本太旧了，才会无法正常的转码。我将 FreeBSD 上的 libiconv 更新为 libiconv-1.11_1，并且重新编译 php4-iconv 的 ports，安装完新版的 php4-iconv 后，中文就可以正常的输出了。<br /><br />不过，在编译 php4-iconv 的 ports 时出现了小插曲，原来的 php4 是使用 autoconf253，但是一直出现下面的错误讯息：<br /><br />configure: error: tag name "CXX" already exists<br />试了一下，修改 /usr/ports/Mk/bsd.php.mk 中的下面这行：<br /><br />WANT_AUTOCONF_VER= 253<br />改成<br /><br />WANT_AUTOCONF_VER= 259<br />再重新 make 后，总算是把 php-iconv 编译好。<img src ="http://www.phpweblog.net/fuyongjie/aggbug/6486.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-05-19 10:50 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/05/19/6486.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php实现excel导入数据库</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/05/18/6485.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Mon, 18 May 2009 14:13:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/05/18/6485.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6485.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/05/18/6485.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6485.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6485.html</trackback:ping><description><![CDATA[<p> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> actionGetUsers() {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #800080">$postfile</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$_POST</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">postfile</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">exit($postfile);</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">            </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #800080">$handle</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">fopen</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$postfile</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">r</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$data</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">fgetcsv</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$handle</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1000</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) { </span>
				<span style="COLOR: #800080">$key_arr</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$data</span>
				<span style="COLOR: #000000">; }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #008080">reset</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$key_arr</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #0000ff">list</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$index</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$name</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">each</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$key_arr</span>
				<span style="COLOR: #000000">)) { </span>
				<span style="COLOR: #800080">$temp_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$name</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$data</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$index</span>
				<span style="COLOR: #000000">]; }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$temp_arr</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #008080">fclose</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$handle</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">dump($result_arr);</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">            </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">/echo $result_arr['username'];</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">            </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #008080">count</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">);</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #800080">$self_intro</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">impChangeCode(</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">self_intro</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]);</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">编码转化<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                //echo $self_intro;</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #800080">$usersManager</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=&amp;</span>
				<span style="COLOR: #000000"> FLEA</span>
				<span style="COLOR: #000000">::</span>
				<span style="COLOR: #000000">getSingleton(</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">Model_Users</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #800080">$user</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">array</span>
				<span style="COLOR: #000000">(<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">username</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">        </span>
				<span style="COLOR: #000000">=&gt;</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">username</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">password</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">        </span>
				<span style="COLOR: #000000">=&gt;</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">password</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">email</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">            </span>
				<span style="COLOR: #000000">=&gt;</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">email</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">gender</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">        </span>
				<span style="COLOR: #000000">=&gt;</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">empty</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">gender</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">])</span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">:</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">gender</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">realname</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">        </span>
				<span style="COLOR: #000000">=&gt;</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">empty</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">realname</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">])</span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">:</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">realname</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">homepage</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">        </span>
				<span style="COLOR: #000000">=&gt;</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">empty</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">homepage</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">])</span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">:</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">homepage</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">self_intro</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #000000">=&gt;</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">empty</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$self_intro</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">:</span>
				<span style="COLOR: #800080">$self_intro</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                    </span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">ip</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">            </span>
				<span style="COLOR: #000000">=&gt;</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">empty</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">ip</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">])</span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">:</span>
				<span style="COLOR: #800080">$result_arr</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">ip</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                );<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">exit($_POST['username']);</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">                </span>
				<span style="COLOR: #800080">$usersManager</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">save(</span>
				<span style="COLOR: #800080">$user</span>
				<span style="COLOR: #000000">);    <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">echo $i;</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">                js_alert(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">批量导入管理员 成功</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">''</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">url(</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">Setpurview</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">List</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">));<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">exit($i);</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">        }<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> impChangeCode(</span>
				<span style="COLOR: #800080">$str</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">//编码转化</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">            {<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />                </span>
				<span style="COLOR: #800080">$str</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> mb_convert_encoding(</span>
				<span style="COLOR: #800080">$str</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">UTF-8</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">CP936</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">cp936即gbk</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">                </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$str</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />            }</span>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6485.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-05-18 22:13 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/05/18/6485.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> 在MySQL中如何为连接添加索引（转）</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/05/09/6468.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Sat, 09 May 2009 03:39:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/05/09/6468.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6468.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/05/09/6468.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6468.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6468.html</trackback:ping><description><![CDATA[<div class="blog_content">简单的3个表的连接 <br /><br /><br />表结构很简单，3个表tblA, tblB, tblC，每个表有3个字段：col1, col2, col3。 <br />在没有索引的情况下连接3个表 <br /><br /><br />SELECT <br />* <br />FROM <br />tblA, <br />tblB, <br />tblC <br />WHERE <br />tblA.col1 = tblB.col1 <br />AND tblA.col2 = tblC.col1; <br /><br /><br />explain的结果如下： <br /><div class="dp-highlighter"><div class="bar"><div class="tools"> </div></div><ol class="dp-j"><li><span><span>+-------+------+---------------+------+---------+------+------+-------------+   </span></span></li><li><span>| table | type | possible_keys | key  | key_len | ref  | rows | Extra       |   </span></li><li><span>+-------+------+---------------+------+---------+------+------+-------------+   </span></li><li><span>| tblA  | ALL  | NULL          | NULL |    NULL | NULL | </span><span class="number"><font color="#c00000">1000</font></span><span> |             |   </span></li><li><span>| tblB  | ALL  | NULL          | NULL |    NULL | NULL | </span><span class="number"><font color="#c00000">1000</font></span><span> | <span class="hilite2">Using</span> where |   </span></li><li><span>| tblC  | ALL  | NULL          | NULL |    NULL | NULL | </span><span class="number"><font color="#c00000">1000</font></span><span> | <span class="hilite2">Using</span> where |   </span></li><li><span>+-------+------+---------------+------+---------+------+------+-------------+  </span></li></ol></div><pre class="java" style="DISPLAY: none" name="code_lighted">   +-------+------+---------------+------+---------+------+------+-------------+
   | table | type | possible_keys | key  | key_len | ref  | rows | Extra       |
   +-------+------+---------------+------+---------+------+------+-------------+
   | tblA  | ALL  | NULL          | NULL |    NULL | NULL | 1000 |             |
   | tblB  | ALL  | NULL          | NULL |    NULL | NULL | 1000 | <span class="hilite2">Using</span> where |
   | tblC  | ALL  | NULL          | NULL |    NULL | NULL | 1000 | <span class="hilite2">Using</span> where |
   +-------+------+---------------+------+---------+------+------+-------------+</pre><br /><br /><br />最后，在<span class="hilite1">MySQL</span>的手册中(7.2.1)： <br />表以它们在处理查询过程中将被<span class="hilite1">MySQL</span>读入的顺序被列出。<span class="hilite1">MySQL</span>用一遍扫描多次联接（single-sweep multi-join）的方式解决所有联接。这意味着<span class="hilite1">MySQL</span>从第一个表中读一行，然后找到在第二个表中的一个匹配行，然后在第3个表中等等。当所有的表处理完后，它输出选中的列并且返回表清单直到找到一个有更多的匹配行的表。从该表读入下一行并继续处理下一个表。 <br />如手册所说的，<span class="hilite1">MySQL</span>读第一个表(tnlA)，然后第二个(tblB)，然后第三个(tblC)，像explain中输出的一样。先前的表中的值用来查找当前表中的行。在我们的例子中，tblA中的值用来找tblB中的匹配行，然后tblB的值来找tblC的行。当一个完整的扫描结束(在表tblA,tblB,tblC中找到了结果)，<span class="hilite1">MySQL</span>不会返回tblA,它到tblB中查看是否有更多的行匹配当前tblA的值。如果有，它拿出这一行，然后再在tblC中找匹配的。记住 <span class="hilite1">MySQL</span>连接的基本原则是很重要的：先前的表中的值用来查找当前表中的行。 <br /><br /><br />按原理建索引 <br /><br />知道了<span class="hilite1">MySQL</span>使用从tblA中得到的值查找tblB中的行，我们需要怎么建索引来帮助<span class="hilite1">MySQL</span>？为此我们要知道它需要什么。考虑连接tblA和 tblB：它们通过“tblA.col1 = tblB.col1”来连接。我们已经有了tblA.col1的值，所以<span class="hilite1">MySQL</span>需要一个tblB.col1的值来完成等值操作。因此如果<span class="hilite1">MySQL</span>需要tblB.col1，我们就在tblB.col1上加索引。加了之后，这是新的explain结果： <br /><br /><div class="dp-highlighter"><div class="bar"><div class="tools"> </div></div><ol class="dp-j"><li><span><span>+-------+------+---------------+----------+---------+-----------+------+-------------+   </span></span></li><li><span>| table | type | possible_keys | key      | key_len | ref       | rows | Extra       |   </span></li><li><span>+-------+------+---------------+----------+---------+-----------+------+-------------+   </span></li><li><span>| tblA  | ALL  | NULL          | NULL     |    NULL | NULL      | </span><span class="number"><font color="#c00000">1000</font></span><span> |             |   </span></li><li><span>| tblB  | ref  | ndx_col1      | ndx_col1 |       </span><span class="number"><font color="#c00000">5</font></span><span> | tblA.col1 |    </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where |   </span></li><li><span>| tblC  | ALL  | NULL          | NULL     |    NULL | NULL      | </span><span class="number"><font color="#c00000">1000</font></span><span> | <span class="hilite2">Using</span> where |   </span></li><li><span>+-------+------+---------------+----------+---------+-----------+------+-------------+  </span></li></ol></div><pre class="java" style="DISPLAY: none" name="code_lighted">+-------+------+---------------+----------+---------+-----------+------+-------------+
| table | type | possible_keys | key      | key_len | ref       | rows | Extra       |
+-------+------+---------------+----------+---------+-----------+------+-------------+
| tblA  | ALL  | NULL          | NULL     |    NULL | NULL      | 1000 |             |
| tblB  | ref  | ndx_col1      | ndx_col1 |       5 | tblA.col1 |    1 | <span class="hilite2">Using</span> where |
| tblC  | ALL  | NULL          | NULL     |    NULL | NULL      | 1000 | <span class="hilite2">Using</span> where |
+-------+------+---------------+----------+---------+-----------+------+-------------+
</pre><br /><br />如上，<span class="hilite1">MySQL</span>现在使用ndx_col1索引来连接tblB到tblA。就是说，当<span class="hilite1">MySQL</span>要找tblB中的行时，使用了ndx_col1索引通过 tblA.col1的值直接得到匹配的行，而不是像以前需要做表扫描。这就是为什么tblB的ref列说“tablA.col1”。tblC现在还是用表扫描，这可以通过同样的方法解决。查看<span class="hilite1">MySQL</span>的需求：从sql中连接两表的语句“tblA.col2 = tblC.col1”可以看出它需要tblC.col1因为我们已经有了tblA.col2。给这一列加上索引之后explain： <br /><br /><div class="dp-highlighter"><div class="bar"><div class="tools"> </div></div><ol class="dp-j"><li><span><span>+-------+------+---------------+----------+---------+-----------+------+-------------+   </span></span></li><li><span>| table | type | possible_keys | key      | key_len | ref       | rows | Extra       |   </span></li><li><span>+-------+------+---------------+----------+---------+-----------+------+-------------+   </span></li><li><span>| tblA  | ALL  | NULL          | NULL     |    NULL | NULL      | </span><span class="number"><font color="#c00000">1000</font></span><span> |             |   </span></li><li><span>| tblB  | ref  | ndx_col1      | ndx_col1 |       </span><span class="number"><font color="#c00000">5</font></span><span> | tblA.col1 |    </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where |   </span></li><li><span>| tblC  | ref  | ndx_col1      | ndx_col1 |       </span><span class="number"><font color="#c00000">5</font></span><span> | tblA.col2 |    </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where |   </span></li><li><span>+-------+------+---------------+----------+---------+-----------+------+-------------+  </span></li></ol></div><pre class="java" style="DISPLAY: none" name="code_lighted">+-------+------+---------------+----------+---------+-----------+------+-------------+
| table | type | possible_keys | key      | key_len | ref       | rows | Extra       |
+-------+------+---------------+----------+---------+-----------+------+-------------+
| tblA  | ALL  | NULL          | NULL     |    NULL | NULL      | 1000 |             |
| tblB  | ref  | ndx_col1      | ndx_col1 |       5 | tblA.col1 |    1 | <span class="hilite2">Using</span> where |
| tblC  | ref  | ndx_col1      | ndx_col1 |       5 | tblA.col2 |    1 | <span class="hilite2">Using</span> where |
+-------+------+---------------+----------+---------+-----------+------+-------------+

</pre><br /><br />更复杂的查询 <br /><br /><br />在实际中不会遇到刚才那种sql。所以你可能更想看看这样的： <br /><br /><br />SELECT <br />COUNT(tblB.a_id) as correct, <br />tblA.type, <br />tblA.se_type <br />FROM <br />tblA, <br />tblB, <br />tblC, <br />tblD <br />WHERE <br />tblA.ex_id = tblC.ex_id <br />AND tblC.st_ex_id = tblB.st_ex_id <br />AND tblB.q_num = tblA.q_num <br />AND tblB.se_num = tblA.se_num <br />AND tblD.ex_id = tblA.ex_id <br />AND tblD.exp &lt;&gt; tblB.se_num <br />AND tblB.ans = tblA.ans <br />AND tblA.ex_id = 1001 <br />AND tblC.r_id = 542 <br />GROUP BY <br />tblA.type, <br />tblA.se_type; <br /><br /><br />乍一看是很复杂的：有4个表，有聚合函数，有9个where条件，还有一个group by。explain的伟大之处在于我们现在可以忽略这些，每次只看两个表，判断每一步<span class="hilite1">MySQL</span>需要什么。这是一个实际的查询，只是字段名有一些改动。explain的结果： <br /><br /><div class="dp-highlighter"><div class="bar"><div class="tools"> </div></div><ol class="dp-j"><li><span><span>+-------+--------+---------------+---------+---------+---------------+-------+----------------------------------------------+   </span></span></li><li><span>| table | type   | possible_keys | key     | key_len | ref           | rows  | Extra                                        |   </span></li><li><span>+-------+--------+---------------+---------+---------+---------------+-------+----------------------------------------------+   </span></li><li><span>| tblA  | ALL    | NULL          | NULL    |    NULL | NULL          |  </span><span class="number"><font color="#c00000">1080</font></span><span> | <span class="hilite2">Using</span> where; <span class="hilite2">Using</span> temporary; <span class="hilite2">Using</span> <span class="hilite3">filesort</span> |   </span></li><li><span>| tblB  | ALL    | NULL          | NULL    |    NULL | NULL          | </span><span class="number"><font color="#c00000">87189</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>| tblC  | eq_ref | PRIMARY       | PRIMARY |       </span><span class="number"><font color="#c00000">4</font></span><span> | tblB.st_ex_id |     </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>| tblD  | eq_ref | PRIMARY       | PRIMARY |       </span><span class="number"><font color="#c00000">4</font></span><span> | tblA.ex_id    |     </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>+-------+--------+---------------+---------+---------+---------------+-------+----------------------------------------------+  </span></li></ol></div><pre class="java" style="DISPLAY: none" name="code_lighted">+-------+--------+---------------+---------+---------+---------------+-------+----------------------------------------------+
| table | type   | possible_keys | key     | key_len | ref           | rows  | Extra                                        |
+-------+--------+---------------+---------+---------+---------------+-------+----------------------------------------------+
| tblA  | ALL    | NULL          | NULL    |    NULL | NULL          |  1080 | <span class="hilite2">Using</span> where; <span class="hilite2">Using</span> temporary; <span class="hilite2">Using</span><span class="hilite3">filesort</span> |
| tblB  | ALL    | NULL          | NULL    |    NULL | NULL          | 87189 | <span class="hilite2">Using</span> where                                  |
| tblC  | eq_ref | PRIMARY       | PRIMARY |       4 | tblB.st_ex_id |     1 | <span class="hilite2">Using</span> where                                  |
| tblD  | eq_ref | PRIMARY       | PRIMARY |       4 | tblA.ex_id    |     1 | <span class="hilite2">Using</span> where                                  |
+-------+--------+---------------+---------+---------+---------------+-------+----------------------------------------------+
</pre><br /><br />判断连接影响的主要看结果集。结果集就是查询的结果。对于连接，一个估计结果集大小的方法是把<span class="hilite1">MySQL</span>预测的读取每个表的行数相乘。作为估计，这样做比较偏向于坏的情况，因为where条件通常会减少很多的行数。但这个查询的结果集有9400万行。这就是没有索引连接很危险的原因；几千行乘几千行你就会有一个上百万的结果集了。 <br />那么现在这个查询需要什么？从tblA和tblB开始。在sql中： <br /><br /><br />AND tblB.q_num = tblA.q_num <br />AND tblB.se_num = tblA.se_num <br />AND tblB.ans = tblA.ans <br /><br /><br /><span class="hilite1">MySQL</span> 至少需要q_num, se_num, ans中的一个。我选择在se_num和q_num上加索引因为在几乎所有其他的查询中我都会需要它们。折中是优化的一部分，多数人没有时间去为每一个查询找最优的索引方案，只能是找到一个对于大多数情况而言最优的方案。在tblB上加索引(se_num, q_num)，explain的结果： <br /><br /><div class="dp-highlighter"><div class="bar"><div class="tools"> </div></div><ol class="dp-j"><li><span><span>+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+   </span></span></li><li><span>| table | type   | possible_keys | key         | key_len | ref                    | rows | Extra                                        |   </span></li><li><span>+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+   </span></li><li><span>| tblA  | ALL    | NULL          | NULL        |    NULL | NULL                   | </span><span class="number"><font color="#c00000">1080</font></span><span> | <span class="hilite2">Using</span> where; <span class="hilite2">Using</span> temporary; <span class="hilite2">Using</span> <span class="hilite3">filesort</span> |   </span></li><li><span>| tblB  | ref    | ndx_secn_qn   | ndx_secn_qn |       </span><span class="number"><font color="#c00000">2</font></span><span> | tblA.se_num,tblA.q_num |  </span><span class="number"><font color="#c00000">641</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>| tblC  | eq_ref | PRIMARY       | PRIMARY     |       </span><span class="number"><font color="#c00000">4</font></span><span> | tblB.st_ex_id          |    </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>| tblD  | eq_ref | PRIMARY       | PRIMARY     |       </span><span class="number"><font color="#c00000">4</font></span><span> | tblA.ex_id             |    </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+  </span></li></ol></div><pre class="java" style="DISPLAY: none" name="code_lighted">+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+
| table | type   | possible_keys | key         | key_len | ref                    | rows | Extra                                        |
+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+
| tblA  | ALL    | NULL          | NULL        |    NULL | NULL                   | 1080 | <span class="hilite2">Using</span> where; <span class="hilite2">Using</span> temporary; <span class="hilite2">Using</span><span class="hilite3">filesort</span> |
| tblB  | ref    | ndx_secn_qn   | ndx_secn_qn |       2 | tblA.se_num,tblA.q_num |  641 | <span class="hilite2">Using</span> where                                  |
| tblC  | eq_ref | PRIMARY       | PRIMARY     |       4 | tblB.st_ex_id          |    1 | <span class="hilite2">Using</span> where                                  |
| tblD  | eq_ref | PRIMARY       | PRIMARY     |       4 | tblA.ex_id             |    1 | <span class="hilite2">Using</span> where                                  |
+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+
</pre><br /><br />现在结果集下降了99.3%变为692280行。但为什么要停在这里？我们可以很容易的解决tblA的表扫描。因为它是第一个表，我们并不需要为连接加索引，这在tblB上已经做过了。一般来说，给第一个表加索引可以把它当成只在这一个表上查询的情况。在这个例子中很幸运，tblA 是："AND tblA.ex_id = 1001"。我们只需要加ex_id索引： <br /><br /><br /><div class="dp-highlighter"><div class="bar"><div class="tools"><a title="复制代码" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://boin.javaeye.com/blog/122845#"></a> </div></div><ol class="dp-j"><li><span><span>+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+   </span></span></li><li><span>| table | type   | possible_keys | key         | key_len | ref                    | rows | Extra                                        |   </span></li><li><span>+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+   </span></li><li><span>| tblA  | ref    | ndx_ex_id     | ndx_ex_id   |       </span><span class="number"><font color="#c00000">4</font></span><span> | </span><span class="keyword">const</span><span>                  |    </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where; <span class="hilite2">Using</span> temporary; <span class="hilite2">Using</span> <span class="hilite3">filesort</span> |   </span></li><li><span>| tblB  | ref    | ndx_secn_qn   | ndx_secn_qn |       </span><span class="number"><font color="#c00000">2</font></span><span> | tblA.se_num,tblA.q_num |  </span><span class="number"><font color="#c00000">641</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>| tblC  | eq_ref | PRIMARY       | PRIMARY     |       </span><span class="number"><font color="#c00000">4</font></span><span> | tblB.st_ex_id          |    </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>| tblD  | eq_ref | PRIMARY       | PRIMARY     |       </span><span class="number"><font color="#c00000">4</font></span><span> | tblA.ex_id             |    </span><span class="number"><font color="#c00000">1</font></span><span> | <span class="hilite2">Using</span> where                                  |   </span></li><li><span>+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+  </span></li></ol></div><pre class="java" style="DISPLAY: none" name="code_lighted">+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+
| table | type   | possible_keys | key         | key_len | ref                    | rows | Extra                                        |
+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+
| tblA  | ref    | ndx_ex_id     | ndx_ex_id   |       4 | const                  |    1 | <span class="hilite2">Using</span> where; <span class="hilite2">Using</span> temporary; <span class="hilite2">Using</span><span class="hilite3">filesort</span> |
| tblB  | ref    | ndx_secn_qn   | ndx_secn_qn |       2 | tblA.se_num,tblA.q_num |  641 | <span class="hilite2">Using</span> where                                  |
| tblC  | eq_ref | PRIMARY       | PRIMARY     |       4 | tblB.st_ex_id          |    1 | <span class="hilite2">Using</span> where                                  |
| tblD  | eq_ref | PRIMARY       | PRIMARY     |       4 | tblA.ex_id             |    1 | <span class="hilite2">Using</span> where                                  |
+-------+--------+---------------+-------------+---------+------------------------+------+----------------------------------------------+
</pre><br /><br />现在结果集是641行。相比开始的9400万，可以说了下降了100%。如果继续研究这个查询我们还可以去掉temp table和<span class="hilite3">filesort</span>，但现在查询已经很快了，也已经说明了如何为连接加索引。尽管最初看这个查询很麻烦，但可以看到只要每次独立的看两张表，为 <span class="hilite1">MySQL</span>的需求加索引，整个过程并不困难。 <br /><br /><br /><font color="#ff0000">结论 <br /></font><br />为复杂的连接加索引要认识到两件事： <br /><br />1. 不管sql多复杂，每次只看explain中的两个表 <br /><br />2. 先前表中的值已经有了，我们的工作就是通过索引帮助<span class="hilite1">MySQL</span>在当前表中使用这些值来找到匹配行 </div>
		<p class="right articalinfo"> </p>
		<h1>
				<font color="white">
						<a href="http://www.78yi.cn">千百亿</a>
				</font>
		</h1><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6468.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-05-09 11:39 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/05/09/6468.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>js中match函数</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/05/04/6461.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Mon, 04 May 2009 03:03:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/05/04/6461.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6461.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/05/04/6461.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6461.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6461.html</trackback:ping><description><![CDATA[js中match函数方法是使用正则表达式模式对字符串执行查找，并将包含查找的结果作为数组返回。使用方法： <br />stringObj.match(rgExp) <br />其中stringObj是必选项。对其进行查找的 String 对象或字符串文字。 <br />rgExp是必选项。为包含正则表达式模式和可用标志的正则表达式对象。也可以是包含正则表达式模式和可用标志的变量名或字符串文字。 <br />如果js中match函数方法没有找到匹配，返回 null。如果找到匹配返回一个数组并且更新全局 RegExp 对象的属性以反映匹配结果。JavaScript中match函数方法返回的数组有三个属性：input、index和lastIndex。Input 属性包含整个的被查找字符串。Index 属性包含了在整个被查找字符串中匹配的子字符串的位置。LastIndex 属性包含了最后一次匹配中最后一个字符的下一个位置。如果没有设置全局标志 (g)，数组的0元素包含整个匹配，而第 1 到 n 元素包含了匹配中曾出现过的任一个子匹配。这相当于没有设置全局标志的 exec 方法。如果设置了全局标志，元素0到n中包含所有匹配。 <br /><br />下面的示例演示了js中match函数方法的用法： <br />function MatchDemo(){ <br />var r, re; // 声明变量。 <br />var s = "The rain in Spain falls mainly in the plain"; <br />re = /ain/i; // 创建正则表达式模式。 <br />r = s.match(re); // 尝试匹配搜索字符串。 <br />return(r); // 返回第一次出现 "ain" 的地方。 <br />} <br /><br />本示例说明带 g 标志设置的js中match函数方法的用法 <br />function MatchDemo(){ <br />var r, re; // 声明变量。 <br />var s = "The rain in Spain falls mainly in the plain"; <br />re = /ain/ig; // 创建正则表达式模式。 <br />r = s.match(re); // 尝试去匹配搜索字符串。 <br />return(r); // 返回的数组包含了所有 "ain" <br />// 出现的四个匹配。 <br />} <br /><br />下面几行代码演示了字符串文字的js中match函数方法的用法。 <br />var r, re = "Spain"; <br />r = "The rain in Spain".replace(re, "Canada"); <br /><br />match()方法用于从字符串中查找指定的值，本方法类似于indexOf()和lastindexOf()，不同的是它返回的是指定的值，而不是指定值在字符串中的位置。indexOf()和lastindexOf()方法返回位置数字 如果找不到返回-1。注意区分大小写 <br />&lt;script type="text/javascript"&gt; <br />var str="Hello world!" <br />document.write(str.match("world") + "") <br />document.write(str.match("World") + "") <br />document.write(str.match("worlld") + "") <br />document.write(str.match("world!")) <br />&lt;/script&gt;<img src ="http://www.phpweblog.net/fuyongjie/aggbug/6461.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-05-04 11:03 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/05/04/6461.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>显示 flash 的代码（IE和FF）</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/04/27/6453.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Mon, 27 Apr 2009 08:59:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/04/27/6453.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6453.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/04/27/6453.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6453.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6453.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">object </span>
				<span style="COLOR: #ff0000">classid</span>
				<span style="COLOR: #0000ff">="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"</span>
				<span style="COLOR: #ff0000"> codebase</span>
				<span style="COLOR: #0000ff">="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"</span>
				<span style="COLOR: #ff0000"> name</span>
				<span style="COLOR: #0000ff">="flashrek"</span>
				<span style="COLOR: #ff0000"> width</span>
				<span style="COLOR: #0000ff">="285"</span>
				<span style="COLOR: #ff0000"> height</span>
				<span style="COLOR: #0000ff">="200"</span>
				<span style="COLOR: #ff0000"> id</span>
				<span style="COLOR: #0000ff">="flashrek"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="movie"</span>
				<span style="COLOR: #ff0000"> value</span>
				<span style="COLOR: #0000ff">="upload/&lt;?=$val['path']?&gt;"</span>
				<span style="COLOR: #ff0000"> </span>
				<span style="COLOR: #0000ff">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="quality"</span>
				<span style="COLOR: #ff0000"> value</span>
				<span style="COLOR: #0000ff">="high"</span>
				<span style="COLOR: #ff0000"> </span>
				<span style="COLOR: #0000ff">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="wmode"</span>
				<span style="COLOR: #ff0000"> value</span>
				<span style="COLOR: #0000ff">="transparent"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000">flash背景透明</span>
				<span style="COLOR: #008000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">embed </span>
				<span style="COLOR: #ff0000">src</span>
				<span style="COLOR: #0000ff">="upload/&lt;?=$v['path']?&gt;"</span>
				<span style="COLOR: #ff0000"> width</span>
				<span style="COLOR: #0000ff">="285"</span>
				<span style="COLOR: #ff0000"> height</span>
				<span style="COLOR: #0000ff">="200"</span>
				<span style="COLOR: #ff0000"> quality</span>
				<span style="COLOR: #0000ff">="high"</span>
				<span style="COLOR: #ff0000"> pluginspage</span>
				<span style="COLOR: #0000ff">="http://www.macromedia.com/go/getflashplayer"</span>
				<span style="COLOR: #ff0000"> type</span>
				<span style="COLOR: #0000ff">="application/x-shockwave-flash"</span>
				<span style="COLOR: #ff0000"> wmode</span>
				<span style="COLOR: #0000ff">="transparent"</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">embed</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">object</span>
				<span style="COLOR: #0000ff">&gt;</span>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6453.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-04-27 16:59 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/04/27/6453.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>20 种提升网页速度的技巧(转)</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/04/27/6452.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Mon, 27 Apr 2009 05:50:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/04/27/6452.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6452.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/04/27/6452.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6452.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6452.html</trackback:ping><description><![CDATA[<p>2009 年 4 月 09 日</p>
		<blockquote>您希望加快网页的加载速度吗？了解如何通过缩短加载时间来改善拨号上网用户的浏览体验，在某些情形下，加载时间最多可缩短 80%。</blockquote>
		<!--START RESERVED FOR FUTURE USE INCLUDE FILES-->
		<!-- include java script once we verify teams wants to use this and it will work on dbcs and cyrillic characters -->
		<!--END RESERVED FOR FUTURE USE INCLUDE FILES-->
		<p>
				<a name="N1004C">
						<span class="atitle">引言</span>
				</a>
		</p>
		<p>不是所有人都能够使用高速 Internet 连接。即使每个人都能够使用高速网络，也会因为各种各样的原因使您的 Web 应用程序看起来运行缓慢。在这个宽带速度不断提高的时代，您应当关注一下页面加载时间。将珍贵的页面加载时间缩短几秒，将更加珍贵的请求和响应时间缩短几毫秒。您将为访问者创造一种更好的体验。</p>
		<p>阅读完本文之后，您将能够较好地了解网页加载时间优化的基本知识。您还能够使用工具和知识更好地识别和判断加载缓慢的页面部分和瓶颈。</p>
		<p>
				<a name="prereqs">
						<span class="atitle">先决条件</span>
				</a>
		</p>
		<p>在理想情况下，您应该安装了 Mozilla Firefox。您还应该大体了解 Web 开发。本文涉及的主题并不复杂，但是如果您了解超文本标记语言（Hypertext Markup Language，HTML）、层叠样式表（Cascading Style Sheet，CSS）以及 ™ 编程语言等主题，那么在学习本文时将更加得心应手。不需要使用集成开发环境（IDE），只需使用您喜爱的编辑器。</p>
		<p>您必须在浏览器中启用了 JavaScript。另外，要学习与 Firebug 和 YSlow 相关的内容，您需要安装 Firefox Web 浏览器。</p>
		<p>
				<a name="broadband">
						<span class="atitle">假设您没有宽带</span>
				</a>
		</p>
		<p>许多人通过某种形式的宽带连接访问 Internet，这些形式可能是 DSL、网线、光纤或其他方法。但是，无法使用这类技术的用户不得不使用拨号连接。您一定已经忘记拨号上网是什么感觉了，但您可以试着回想一下网页逐行加载时的情形。</p>
		<table cellspacing="0" cellpadding="0" width="40%" align="right" border="0">
				<tbody>
						<tr>
								<td width="10">
										<img height="1" alt="" src="http://www.ibm.com/i/c.gif" width="10" />
								</td>
								<td>
										<table cellspacing="0" cellpadding="5" width="100%" border="1">
												<tbody>
														<tr>
																<td bgcolor="#eeeeee">
																		<p>2006 Organization for Economic Cooperation and Development (OECD) 报告将<i>宽带</i> 定义为数据下载速率大于 256 kbit/s 的连接。美国 Federal Communications Commission (FCC) 目前将宽带定义为大于 768 kbit/s 速率的所有连接方式。</p>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<p>幸运的是，这些可怜的人们现在已经能够获得一些帮助。您可以通过缩短加载页面的时间来改善他们的体验。但是，拨号连接并不是降低加载和响应速度的惟一原因。许多 Web 设计人员错误地认为高速 Internet 连接的到来会使网站性能优化变得没有必要。这种观点是不对的。例如，过去使用桌面软件执行的许多任务现在可以在线执行。在 Web 应用程序中获得像桌面软件那样的高速响应体验非常困难，因此性能优化非常重要。幸运的是，一些工具和最佳实践可用于缩短响应和加载时间，提供更加流畅的体验。</p>
		<table cellspacing="0" cellpadding="0" width="40%" align="right" border="0">
				<tbody>
						<tr>
								<td width="10">
										<img height="1" alt="" src="http://www.ibm.com/i/c.gif" width="10" />
								</td>
								<td>
										<table cellspacing="0" cellpadding="5" width="100%" border="1">
												<tbody>
														<tr>
																<td bgcolor="#eeeeee">
																		<p>根据 Birds-Eye 的 2007 宽带统计显示，美国境内 25% 的人没有 Internet 连接，53% 的人拥有宽带，21% 的人仍然在使用拨号连接。</p>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<p>
				<a name="toolsessentials">
						<span class="atitle">基本工具</span>
				</a>
		</p>
		<p>对于所有与优化相关的任务，您必须使用工具来诊断瓶颈和识别问题。现在在 Web 开发中使用最广泛的两个工具是 Firebug 和 YSlow，它们都是开源、免费的 Firefox 插件。 </p>
		<p>
				<a name="firebug">
						<span class="smalltitle">Firebug</span>
				</a>
		</p>
		<p>Firebug（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考资料</a>）是最流行的 Firefox 扩展之一，该应用程序能够使 Web 开发人员的工作更加轻松。它包含许多非常有用的功能，比如：</p>
		<ul>
				<li>JavaScript 调试</li>
				<li>JavaScript 命令行</li>
				<li>监视 JavaScript 性能和跟踪 <code>XmlHttpRequests</code></li>
				<li>登录 Firebug 控制台</li>
				<li>跟踪</li>
				<li>检查 HTML 元素和动态编辑 HTML 代码</li>
				<li>动态编辑 CSS 文档</li>
		</ul>
		<p>
				<a name="yslow">
						<span class="smalltitle">YSlow</span>
				</a>
		</p>
		<p>YSlow（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考资料</a>）分析网页，并根据 Yahoo! 起草的高性能网站规则（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考</a>），告诉您网页加载缓慢的原因。YSlow 是一个与 Firebug 集成的 Firefox 插件，因此您需要首先安装 Firebug，然后才能安装和使用 YSlow。</p>
		<p>
				<a name="installfirebug">
						<span class="atitle">安装 Firebug</span>
				</a>
		</p>
		<p>两个 Firefox 扩展的安装过程都非常简单。要安装 Firebug，执行以下步骤：</p>
		<ol>
				<li>打开 Firefox，转到 <a href="http://www.getfirebug.com/">Firebug 主页</a>。</li>
				<li>安装最新版的 Firebug。</li>
				<li>如果 Firefox 配置为阻止弹出窗口，单击 <b>Allow</b> 允许打开安装窗口。否则，单击 <b>Install Now</b>。 </li>
				<li>重启 Firefox。</li>
		</ol>
		<p>您现在可以从 Tools 菜单访问 Firebug。可以在新窗口或现有窗口中打开 Firebug（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#fig1">图 1</a>）。 </p>
		<br />
		<a name="fig1">
				<b>图 1. Firefox 起始页的 Firebug HTML 和 Style 视图</b>
		</a>
		<br />
		<img height="231" alt="Firebug 视图" src="http://www.ibm.com/developerworks/cn/web/wa-speedweb/firebuginstalled.jpg" width="500" />
		<br />
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="installyslow">
						<span class="atitle">安装 YSlow</span>
				</a>
		</p>
		<p>安装 Firebug 之后，接下来安装 YSlow。为此，执行以下步骤：</p>
		<ol>
				<li>打开 Firefox，然后转到 <a href="http://developer.yahoo.com/yslow">YSlow 主页</a>。 </li>
				<li>安装插件，然后重启 Firefox。
<p><b>注意：</b>与许多其他 Firefox 扩展不同，YSlow 不会自动启动。必须首先激活它。 </p></li>
				<li>要激活 YSlow，在状态栏右键单击其图标，然后单击 <b>Autorun</b>。 </li>
		</ol>
		<p>
				<a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#fig2">图 2</a> 显示了 YSlow 性能分析的结果。</p>
		<br />
		<a name="fig2">
				<b>图 2. Firefox 起始页的 YSlow 性能分析</b>
		</a>
		<br />
		<img height="233" alt="YSlow 性能分析" src="http://www.ibm.com/developerworks/cn/web/wa-speedweb/yslow-performancetab.jpg" width="500" />
		<br />
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="commonsense">
						<span class="atitle">常识：牢记设计规则</span>
				</a>
		</p>
		<p>令人惊讶的是简单的设计规则通常会被忽视，最终产生未经优化的、下载缓慢的网页。牢记以下规则，页面的加载速度将会更快。</p>
		<p>
				<a name="goodstructure">
						<span class="atitle">使用良好的结构</span>
				</a>
		</p>
		<p>可扩展 HTML (XHTML) 具有许多优势，但是其缺点也很明显。XHTML 可能使您的页面更加符合标准，但是它大量使用标记（强制性的 <code>&lt;start&gt;</code> 和 <code>&lt;end&gt;</code> 标记），这意味着浏览器要下载更多代码。所以，事情都有两面性，尝试在您的网页中使用较少的 XHTML 代码，以减小页面大小。</p>
		<p>如果您确实不得不使用 XHTML，试着尽可能对它进行优化。例如，删除空格并采用严格的 XHTML 编码实践，提高下载和解析速度。要严格执行 XHTML Strict 规则，向文档中添加以下 <code>doctype</code> 语句： </p>
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"      
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>XHTML 1.0 Strict 与 Strict HTML 4.01 是等效的，包含的属性和元素没有出现在 HTML 4.01 规范的反对内容中。记住，有两个标记能够在 XHTML Transitional 中使用，但不能在 XHTML Strict 中使用，例如：</p>
		<ul>
				<li>
						<code>&lt;center&gt;</code>
				</li>
				<li>
						<code>&lt;font&gt;</code>
				</li>
				<li>
						<code>&lt;iframe&gt;</code>
				</li>
				<li>
						<code>&lt;strike&gt;</code>
				</li>
				<li>
						<code>&lt;u&gt;</code>
				</li>
		</ul>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="overload">
						<span class="atitle">不要使布局超载</span>
				</a>
		</p>
		<p>在博客（和新的站点）流行起来之前，让页面水平滚动甚至垂直滚动被认为是糟糕的实践。页面越小，越难以（但并不是不可能）完好地填充屏幕。现在，对于博客和内容驱动的网站，不时可以看到几百 Kb 大小的长页面。是的，您需要填充更多空间，但是这并不意味着您必须使用大的背景图像、大量表格或者许多内容来填充。坚持简约原则：少即是多。页面中充斥着各种类型的图像、视频、广告等，这大大违背实用性原则，因此，在增加页面的内容时请三思。 </p>
		<p>
				<a name="imagestext">
						<span class="atitle">不要使用图像来表示文本</span>
				</a>
		</p>
		<p>我们很少会控制字体在不同浏览器中的显示方式，与字体不同的是，图像总是精确地按照其设计方式来显示。但这不能当作使用图像来表示文本的借口。</p>
		<p>使用图像表示文本的最常见示例就是在导航栏中。美观的按钮更加具有吸引力，但是它们的加载速度很慢。此外，图像仍然不能由搜索引擎直接索引，因此，使用图像进行导航不利于搜索引擎优化（search engine optimization，SEO）。当无需图像就可以通过大量 CSS 技巧创建漂亮的按钮时，绝不使用图像来表示文本。</p>
		<p>一种适用于 CSS 样式的特定导航类型就是选项卡式导航，如 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#fig3">图 3</a> 所示。 </p>
		<br />
		<a name="fig3">
				<b>图 3. 选项卡式导航</b>
		</a>
		<br />
		<img height="33" alt="选项卡式导航" src="http://www.ibm.com/developerworks/cn/web/wa-speedweb/tabs.jpg" width="500" />
		<br />
		<p>除了体积较小之外，这种实现导航的方式也更加符合 Web 标准。</p>
		<table cellspacing="0" cellpadding="0" width="40%" align="right" border="0">
				<tbody>
						<tr>
								<td width="10">
										<img height="1" alt="" src="http://www.ibm.com/i/c.gif" width="10" />
								</td>
								<td>
										<table cellspacing="0" cellpadding="5" width="100%" border="1">
												<tbody>
														<tr>
																<td bgcolor="#eeeeee">
																		<p>遵循统称为 <i>Web 标准</i> 的一组最佳实践的网站具有精简性、可访问性、搜索引擎友好性、适用性和基于 CSS 的特征。</p>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<p>
				<a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#list1">清单 1</a> 和 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#list2">清单 2</a> 中的代码以纯 CSS/XHTML 的形式实现基于选项卡的导航功能。 </p>
		<br />
		<a name="list1">
				<b>清单 1. 基于选项卡导航的 CSS 文档</b>
		</a>
		<br />
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">				
    #nav {
      float:left;
      width:100%;
      background:#E7E5E2;
      font-size:95%;
      line-height:normal;
      border-bottom:1px solid #54545C;
      }
    #nav ul {
	margin:0;
	padding:10px 10px 0 50px;
	list-style:none;
      }
    #nav li {
      display:inline;
      margin:0;
      padding:0;
      }
    #nav a {
      float:left;
      background:url("tableftK.gif") no-repeat left top;
      margin:0;
      padding:0 0 0 4px;
      text-decoration:none;
      }
    #nav a span {
      float:left;
      display:block;
      background:url("tabrightK.gif") no-repeat right top;
      padding:5px 15px 4px 6px;
      color:#FFF;
      }
    /* Commented Backslash Hack hides rule from IE5-Mac \*/
    #nav a span {float:none;}
    /* End IE5-Mac hack */
    #nav a:hover span {
      color:#FFF;
	  background-position:100% -42px;
      }
    #nav a:hover {
      background-position:0% -42px;
      }
    #nav a:hover span {
      background-position:100% -42px;
	  }
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<a name="list2">
				<b>清单 2. 基于选项卡导航的 HTML 代码</b>
		</a>
		<br />
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">				
&lt;div id="nav"&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href="#" title="Link 1"&gt;&lt;span&gt;Link 1&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#" title="Link 2"&gt;&lt;span&gt;Link 2&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#" title="Link 3"&gt;&lt;span&gt;Link 3&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#" title="Longer Link Text"&gt;&lt;span&gt;Longer Link Text&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#" title="Link 5"&gt;&lt;span&gt;Link 5&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="cookie">
						<span class="atitle">检查 cookie 使用情况</span>
				</a>
		</p>
		<p>cookie 可能是很小的文件，但是浏览器仍然需要下载它们。较大的 cookie 所需的下载时间更长，进而增加了浏览器加载网页的时间。正因为如此，尽可能缩小 cookie 来最小化对浏览器响应时间的影响非常重要。</p>
		<p>此外，设置一个较早的 <code>expire</code> 日期或者根本不设置 <code>expire</code> 日期，会缩短响应时间。要在 PHP 语言中设置 cookie 的 <code>expire</code> 日期，使用以下代码： </p>
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">&lt;?php 
 $expire = 2592000 + time(); 
 // Add 30 day’s to the current time 
 setcookie(userid, “123rrw3”, $expire);
?&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>这段代码设置 cookie <code>userid</code>，并将 <code>expire</code> 日期设置为自当前日期之后 30 天。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="jojs">
						<span class="atitle">不要包含不必要的 JavaScript 代码，尽可能将其外部化</span>
				</a>
		</p>
		<p>与 cookie 类似，JavaScript 文件的下载也需要时间，这不可避免地会降低整个页面的加载速度。因此，明智地使用 JavaScript（仅在真正必要时才使用）并优化脚本的大小和速度。</p>
		<p>缩短 JavaScript 下载时间的另一种方式是使用外部文件，而不是包含脚本内联。这种方法也适用于 CSS，因为浏览器会缓存外部化的文本，而（在 HTML 页面自身中）以内联方式编码的 CSS 或 JavaScript 每次都会随 HTML 一起加载。要通过在 HTML 中引用 CSS 和 JavaScript 代码来外部化它们，可以使用具有以下形式的代码： </p>
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">&lt;link href="/stylesheets/myStyle.css" media="all" rel="Stylesheet" type="text/css" /&gt;
   &lt;script src="/javascripts/myJavascript.js" type="text/javascript"&gt;&lt;/script&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>
				<a name="avoidtables">
						<span class="atitle">尽可能避免使用表格</span>
				</a>
		</p>
		<p>表格被用作网页的主要构建块，但是作为页面布局元素，使用表格现在被认为是糟糕的做法。有时候，您必须使用表格（并且它们被认为是显示表格数据的出色实践）。如果是这样，明确地指定表格单元格、行和列的宽度和高度，否则，浏览器必须执行许多操作来计算如何显示它们，这会降低页面加载速度： </p>
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">&lt;td width="50px" height="10px"&gt;...&lt;/td&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>
				<a name="remove">
						<span class="atitle">删除任何不必要的元素</span>
				</a>
		</p>
		<p>可能这是所有技巧中最显而易见的一个，但是它也是最容易忘记的一个技巧。我曾经提到过 “少即是多”：这不仅是为了真正吸引更广泛的用户，还意味着需要下载和处理的东西更少。如果您真正需要在网页上放置许多内容，考虑将网页分为 2 个、3 个或更多的独立页面。 </p>
		<p>
				<a name="tips">
						<span class="atitle">一些优化网页的技巧</span>
				</a>
		</p>
		<p>可以使用许多方法来优化您的网页，包括压缩 JavaScript 文件，使用超文本传输协议（Hypertext Transfer Protocol，HTTP）压缩，以及设置图像大小。</p>
		<p>
				<a name="compressjs">
						<span class="atitle">压缩和缩小 JavaScript 文件</span>
				</a>
		</p>
		<p>JavaScript 文件可能非常大，这意味着在某些情形中，它们的下载时间可能比所有其他组件下载时间之和还长。解决此问题的一种方法是压缩 JavaScript 文件。您可以使用 GNU zip (gzip) 来完成此任务，因为许多浏览器都支持这种压缩算法。</p>
		<p>另一种替代方法是缩小文件。这种方法删除代码中所有不必要的字符，比如制表符（tab）、新行和空格。它删除代码中的注释和空白，进一步缩小文件大小。外部和内部样式表都可以缩小。两种最流行的缩小工具是 JSMin 和 YUI Compressor（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考资料</a>）。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="httpcompression">
						<span class="atitle">使用 HTTP 压缩，并始终使用小写的 div 和类名</span>
				</a>
		</p>
		<p>可以使用 HTTP 压缩来减少服务器与浏览器之间的通信量。可以在 Apache 中配置 HTTP 压缩（.htaccess 文件），或者可以将其包含到页面中（对于 PHP，可以使用一个 <code>HTTP_ACCEPT_ENCODING</code> 选项）。但是请注意：不是所有浏览器都支持压缩。即使是支持压缩的浏览器，压缩和解压缩都会加重处理器的负载。要在 Apache 中启用地毯式（blanket）压缩（即压缩所有文本和 HTML），使用以下命令：</p>
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">AddOutputFilterByType DEFLATE text/html text/plain text/xml
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>另外，考虑一下您想要压缩的内容。图像、音乐和视频在创建时已经进行了压缩，因此您可以将压缩对象限制为 HTML、CSS 和 JavaScript 文件。</p>
		<p>另一种减少压缩工作的技巧是使用小写形式的 <code>&lt;div&gt;</code> 元素和类名。由于大小写敏感性，并且使用的是无损压缩，<code>&lt;header&gt;</code> 与 <code>&lt;Header&gt;</code> 不同，它们被压缩为两个不同的标记。在下面的例子中，对于压缩程序来说，<code>Important</code> 类与 <code>important</code> 类是不同的，这意味着对于压缩程序，它们表示不同的对象，因此被分别压缩为两段不同的文本。 </p>
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">&lt;div class="Important"&gt;read this!&lt;/div&gt;
&lt;div class="important"&gt;This will cost you some valuable load time&lt;/div&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>留意细节似乎无关紧要。但是当您优化文件时，所有细微的细节都应考虑在内。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="setimagesize">
						<span class="atitle">设置图像大小</span>
				</a>
		</p>
		<p>与表格单元格、行和列一样，当您未明确设置图像大小时，浏览器需要执行计算来显示图像，这会降低处理速度。此外，在某些情形下，图像大小的计算结果可能不正确，因此图像会发生变形。</p>
		<p>
				<a name="cssimage">
						<span class="atitle">将 CSS 图像映射用于装饰功能</span>
				</a>
		</p>
		<p>使用图像映射代替多个图像，这是另一种缩短加载时间的方式，因为同时下载图像的各个独立部分能够加快整个页面的下载进度。或者，您可以使用某种名为 <i>CSS sprites</i> 的工具（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考资料</a>）。CSS sprites 可帮助减少 HTTP 请求的数量。一个图像可以包含装饰或布置页面所需的所有图像元素。您使用 CSS 来选择（通过调用某些位置和维度）用于特定元素的映射。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="delayload">
						<span class="atitle">尽可能延迟脚本加载</span>
				</a>
		</p>
		<p>我 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#jojs">在前面</a> 提到过，移除完全不需要的 JavaScript 代码能够加快加载和处理速度。但是如果代码已经非常精简并且必须在页面中包含 JavaScript 代码的话，该怎么办？</p>
		<p>在这种情形下，一种提升页面下载速度的潜在方式是将脚本放在页面的底部，使页面加载更迅速。通常，浏览器只能（从同一个域）下载不超过两个并行对象，如果一个对象是一段 JavaScript 代码，那么在该脚本下载完之前，其他页面组件的下载将会暂停。如果将 JavaScript 代码放在页面底部，（在大多数情况下）它将在最后下载，这时所有其他组件都已下载完。</p>
		<p>使用 Firebug 扩展跟踪加载缓慢的文件，我敢打赌您的 JavaScript 文件是下载最慢的文件。压缩 JavaScript 文件会有所帮助，但是仅仅这样可能还不够。您可以使用以下代码片段延迟 JavaScript 的加载： </p>
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">var delay = 5;
setTimeout("heavy();", delay * 1000);
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>这段代码将对 <code>heavy()</code> 方法的调用延迟了 5 秒。您可以将这段代码与下面的技巧结合使用来延迟整个 JavaScript 文件的加载。</p>
		<p>
				<a name="loadondemand">
						<span class="smalltitle">按需加载 JavaScript 文件</span>
				</a>
		</p>
		<p>要按需加载 JavaScript，使用 import() 函数，如 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#list3">清单 3</a> 所示。</p>
		<br />
		<a name="list3">
				<b>清单 3. import() 函数</b>
		</a>
		<br />
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">				
function $import(src){
  var scriptElem = document.createElement('script');
  scriptElem.setAttribute('src',src);
  scriptElem.setAttribute('type','text/javascript');
  document.getElementsByTagName('head')[0].appendChild(scriptElem);
}

// import with a random query parameter to avoid caching
function $importNoCache(src){
  var ms = new Date().getTime().toString();
  var seed = "?" + ms; 
  $import(src + seed);
}
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>
				<a name="verifyload">
						<span class="smalltitle">验证函数加载</span>
				</a>
		</p>
		<p>也可以验证一个函数是否被加载，如果没有，加载 JavaScript 文件。为此，使用 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#list4">清单 4</a> 中的代码。 </p>
		<br />
		<a name="list4">
				<b>清单 4. 验证函数是否被加载</b>
		</a>
		<br />
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">				
if (myfunction){
  // The function has been loaded
}
else{ // Function has not been loaded yet, so load the javascript.
  $import('http://www.yourfastsite.com/myfile.js');
}
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>
				<b>注意：</b>可以使用 <code>defer</code> 属性，但不是所有浏览器（包括 Firefox）都支持它。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="optimizecss">
						<span class="atitle">优化 CSS 文件</span>
				</a>
		</p>
		<p>如果经过适当优化和维护，CSS 文件不一定很大。例如，具有很多独立类的 CSS 文件会影响下载速度。与 JavaScript 文件一样，您需要优化 CSS 文件，使其包含所需的所有内容，同时保持合理的大小。另外，使用外部文件代替内联定义来适应浏览器的缓存机制。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="cdn">
						<span class="atitle">使用内容分布网络</span>
				</a>
		</p>
		<p>内容分布网络（Content-distribution network，CDN）是另一种缩短下载时间的好方法。当您将静态图像放在 Internet 上的许多服务器上时，用户能够从离他们最近的服务器下载这些图像。此外，大多数 CDN 都在快速服务器上运行，因此无论服务器的加载速度如何，其响应速度都比小型的超载服务器快。</p>
		<p>
				<a name="multipledomains">
						<span class="atitle">对资产使用多个域来增加连接</span>
				</a>
		</p>
		<p>CDN 的另一个优势是它们是独立的域。因为您的浏览器将并发连接的数量限制到一个单一的域，因此无论何时加载一个页面，都很容易占满所有线程。因此，到其他资产的连接被延迟了。然而，您的浏览器能够打开新线程或到其他域的连接，这样，从另一个域加载的任何资产都可以与其他所有资产同时加载。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="gears">
						<span class="atitle">在合适的时候使用 Google Gears</span>
				</a>
		</p>
		<p>使用 Google Gears（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考资料</a>）是避免用户反复下载同一内容的另一种好方法。Gears 允许用户离线访问 Web 应用程序，但是也允许将页面元素持久化到用户的计算机上。因此，频繁加载但未进行更新的内容可以存储在 Gears 数据库中，该数据库是一个 SQLite3 关系数据库管理系统。对同一内容的所有 <code>next</code> 请求都可以从数据库（而不是服务器）直接加载。</p>
		<p>安装 Gears 之后，获取 gears_init.js 文件，以便轻松访问 <a href="http://code.google.com/apis/gears/gears_init.js">Gears 工厂和应用程序编程接口（API）</a>，将其保存为 <i>gears_init.js</i>，通过以下方式在您的代码中引用它：</p>
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">&lt;script type="text/javascript" src="gears_init.js"&gt;&lt;/script&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>要确定是否已安装 Gears，使用 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#list5">清单 5</a> 中的代码。</p>
		<br />
		<a name="list5">
				<b>清单 5. 确定是否已安装 Gears</b>
		</a>
		<br />
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">				
&lt;script&gt;
  if (!window.google || !google.gears) {
    location.href = "http://gears.google.com/?action=install&amp;message=&lt;welcome message&gt;" 
        + "&amp;return=&lt;return url&gt;";
  }
&lt;/script&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>如果未安装 Gears，代码将向您提供下载 Gears 的 URL。</p>
		<p>当所有元素都通过验证并且 Gears 已安装之后，您可以测试 Gears 的极其有用的数据库功能，使用 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#list6">清单 6</a> 中的 JavaScript 代码。 </p>
		<br />
		<a name="list6">
				<b>清单 6. 测试数据库功能</b>
		</a>
		<br />
		<table cellspacing="0" cellpadding="0" width="50%" border="0">
				<tbody>
						<tr>
								<td class="code-outline">
										<pre class="displaycode">				
&lt;script type="text/javascript"&gt;
 var db = google.gears.factory.create('beta.db');
 db.open('database-test');
 db.execute('create table if not exists Test' +
           ' (Phrase text, Timestamp int)');
 db.execute('insert into Test values (?, ?)', ['Monkey!', new Date().getTime()]);
 var rs = db.execute('select * from Test order by Timestamp desc');

 while (rs.isValidRow()) {
  alert(rs.field(0) + '@' + rs.field(1));
  rs.next();
 }
 rs.close();
&lt;/script&gt;
</pre>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<p>这段代码在您的计算机或服务器上创建一个本地数据库 <i>db。</i>如果表 <i>Test</i> 不存在，则创建一个，然后插入测试数据（<i>Monkey!</i> 和时间）。代码从数据库获取数据，并在浏览器中以警告的形式呈现出来。</p>
		<p>想像一下可能发生的结果！</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="png">
						<span class="atitle">使用 PNG 格式的图像</span>
				</a>
		</p>
		<p>Graphic Interchange Format (GIF) 和 Joint Photographic Experts Group (JPEG) 图像格式都已过时了：Portable Network Graphic (PNG) 是未来流行的格式。当然，您可以说 GIF 和 JPEG 已经消亡，或者 PNG 没有任何缺陷，但是所有事物都有各自的优缺点，PNG 以最佳的文件大小提供了出色的质量。因此，如果进行选择的话，应该尽可能使用 PNG 图像。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="shortajax">
						<span class="atitle">保持 Ajax 调用简短、准确</span>
				</a>
		</p>
		<p>当统称为 Asynchronous JavaScript + XML (Ajax) 的技术在两年前出现时，这些技术为处理页面请求和响应提供了一种革命性方法。然而，拨号用户可能从来没机会体验其真正的优势，因为在许多情形下，Ajax 需要在浏览器与服务器之间大量通信。因此，如果您能够保持 Ajax 调用简短和准确，可以避免用户花费无止尽的时间来等待元素刷新或响应。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="oneajax">
						<span class="atitle">进行一次较大的 Ajax 调用并在本地处理客户机数据</span>
				</a>
		</p>
		<p>如果不能进行简短的 Ajax 调用，或者如果这些调用不能提供期望的结果，可以考虑一种替代方法：进行一次大的 Ajax 调用来获取所需的一切内容，然后让客户机在本地处理数据。通过这种方式，客户机只需等待一次（获取传入的数据），但是在此之后（当浏览器与服务器之间没有必要通信时），处理速度将更快。当然，还有大量 Ajax 优化技术，本教程无法一一列出。如果想要了解关于 Ajax 的更多信息，请查看 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考资料</a>。 </p>
		<p>
				<a name="sandbox">
						<span class="atitle">在沙箱中测试代码</span>
				</a>
		</p>
		<p>还有一个经常被遗忘的常用技巧。尽管清醒的 Web 开发人员通常会在启动应用程序之前对其进行测试，但是有时候测试会使他们不那么重视维护任务，或者新功能添加得太快，并且未经过充分考虑或测试。结果，余下的脚本减缓了应用程序的速度。</p>
		<p>如果您添加一项新功能，可以首先在沙箱里（完全脱离了应用程序的其余部分）进行测试，查看它作为单个函数的行为。通过这种方式，您可以反复检查，并分析性能和响应时间，无需考虑 Web 应用程序的其余部分。然后，当新功能的行为符合预期时，可以将其引入到应用程序的其余部分中，运行其他测试，保证功能本身的行为符合预期。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="analyze">
						<span class="atitle">分析站点代码</span>
				</a>
		</p>
		<p>在许多场景中，自我反省是一个不错的建议。幸运的是，在开发过程中，我们可以使用工具来帮助反省，并尽可能客观地进行实践。像 JSLint（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考资源</a>）这样的工具的价值是无法衡量的，尽管其站点宣称它 “可能令您备受挫折”，因为它向您提供了所有的潜在代码缺陷，这些缺陷不但使调试更加困难，而且可能导致更长的响应时间。 </p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="jslint">
						<span class="atitle">使用 JSLint 检查 JavaScript 代码中的错误或糟糕的编码实践</span>
				</a>
		</p>
		<p>您不需要像完美主义者那样追求完美无缺的 JavaScript 代码。但是，许多开发人员没有认真对待代码分析，通常在开发过程中跳过了这个步骤。不幸的是，错误和糟糕的编码实践不仅不太专业，而且可能减缓应用程序的速度。当浏览器忙于应付错误和糟糕的编码实践时，加载不仅需要更多时间，还会导致难以调试的错误。 </p>
		<p>因此，如果想要获得良好的代码，可以考虑使用代码分析工具。有许多不同的工具可供使用，但是最适合 JavaScript 语言的工具非 JavaScript Lint 莫属，它也叫做 JSLint（参见 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#resources">参考资料</a>）。也可以使用 Firebug，但是 JSLint 更加正式，它包含在 YSlow 中。 </p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="orphans">
						<span class="atitle">检查孤立的文件和丢失的图像</span>
				</a>
		</p>
		<p>检查孤立的文件和丢失的图像是一种明智之举。大部分 Web 开发人员都会检查错误的文件引用，但是这里仍然需要说明一下。丢失的文件容易引起各种问题，因为它们会导致 “The image/page cannot be displayed” 之类的错误消息。但是在网页速度优化方面，它们具有更大的缺陷：当浏览器寻找丢失的或孤立的文件时，它会消耗资源，这不可避免地会导致页面处理速度变慢。因此，请检查孤立或丢失的文件，包括拼写错误的文件名。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="YSlow">
						<span class="atitle">YSlow 扩展</span>
				</a>
		</p>
		<p>YSlow Firebug 扩展使主观的网页分析日渐被淘汰。YSlow 使用 Yahoo! 起草的面向高性能网站的权威规则，分析网页并告诉您它们变慢的原因。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="analyzepgs">
						<span class="atitle">使用 YSlow 分析网页</span>
				</a>
		</p>
		<p>YSlow 是一个相对较小但非常有用的 Firefox 扩展。当启动 YSlow 时，该扩展在浏览器的下半部分中打开，如 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#fig4">图 4</a> 所示。</p>
		<br />
		<a name="fig4">
				<b>图 4. Firefox 中的 YSlow 扩展 </b>
		</a>
		<br />
		<img height="249" alt="Firefox 中的 YSlow 扩展" src="http://www.ibm.com/developerworks/cn/web/wa-speedweb/PerformanceView.jpg" width="500" />
		<br />
		<p>图 4 显示了 Performance 视图，可以在其中看到 YSlow 如何评估您的网页的性能，还能够看到该扩展检测到的问题。单击列表中的一个链接将打开一个页面，其中解释了相应的错误。如果存在可以改进的页面组件，YSlow 会给出改进建议。</p>
		<p>在 Inspect 视图中，如 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#fig5">图 5</a> 所示，您可以逐一分析元素来剖析页面。Inspect 视图的一个最有用的功能是，当您在页面上移动鼠标指针时，它会自动刷新，因此您无需通过滚动代码内容来查找需要检查的行。 </p>
		<br />
		<a name="fig5">
				<b>图 5. Firefox 中的 YSlow Inspect 视图</b>
		</a>
		<br />
		<img height="298" alt="YSlow Inspect 视图" src="http://www.ibm.com/developerworks/cn/web/wa-speedweb/InspectView.jpg" width="500" />
		<br />
		<p>从 Stats 视图的名称可以猜测到，它（如 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#fig6">图 6</a> 所示）显示与当前页面有关的统计数据。这些数据包括空的和主要的缓存和 cookie。</p>
		<br />
		<a name="fig6">
				<b>图 6. Firefox 中的 YSlow Stats 视图</b>
		</a>
		<br />
		<img height="350" alt="YSlow Stats 视图" src="http://www.ibm.com/developerworks/cn/web/wa-speedweb/StatsView.jpg" width="500" />
		<br />
		<p>Components 视图（如 <a href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#fig7">图 7</a> 所示）列出了当前页面上的组件。显示的与每个组件有关的数据包括文件类型和路径、页面过期时间以及 HTTP 响应报头。单击一个组件可以将其打开，以供查看。单击一个列标题可以按升序或降序对表进行排序。</p>
		<br />
		<a name="fig7">
				<b>图 7. YSlow Components 视图</b>
		</a>
		<br />
		<img height="239" alt="YSlow Components 视图" src="http://www.ibm.com/developerworks/cn/web/wa-speedweb/ComponentsView.jpg" width="500" />
		<br />
		<p>YSlow 是一个较小的、有用的扩展，可以在提高页面加载速度方面为您提供许多帮助。如果您以前未使用过它，那么现在应该使用了。</p>
		<br />
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td>
										<img height="1" alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%" />
										<br />
										<img height="6" alt="" src="http://www.ibm.com/i/c.gif" width="8" border="0" />
								</td>
						</tr>
				</tbody>
		</table>
		<table class="no-print" cellspacing="0" cellpadding="0" align="right">
				<tbody>
						<tr align="right">
								<td>
										<img height="4" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
										<br />
										<table cellspacing="0" cellpadding="0" border="0">
												<tbody>
														<tr>
																<td valign="center">
																		<img height="16" alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width="16" border="0" />
																		<br />
																</td>
																<td valign="top" align="right">
																		<a class="fbox" href="http://www.ibm.com/developerworks/cn/web/wa-speedweb/?S_TACT=105AGX52&amp;S_CMP=tec-csdn#main">
																				<b>回页首</b>
																		</a>
																</td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<p>
				<a name="summary">
						<span class="atitle">结束语</span>
				</a>
		</p>
		<p>优化网页的加载速度并不复杂。实际上，您通常可以轻而易举地实现速度优化。如果遵循本文中介绍的技巧以及 Web 开发最佳实践，那么无需采用其他措施就可以提高页面的加载速度。</p>
		<p>将大量页面优化技巧收集到一起很简单，我希望本文的资源具有一定的价值。但是，如果您认为速度优化技巧只有这里列出的这些，那么您将惊奇地发现远远不止这些。但是，即使您仅遵循这 20 多个技巧，您的页面的加载速度也会更快，您的用户也会更惬意 —— 无论他们通过拨号还是专用的宽带上网。</p>
		<br />
		<br />
		<p>
				<a name="resources">
						<span class="atitle">参考资料 </span>
				</a>
		</p>
		<b>学习</b>
		<br />
		<ul>
				<li>在 Wikipedia 上查找 <a href="http://en.wikipedia.org/wiki/Broadband_Internet_access">与宽带网络接入相关的一般信息和指标</a>。<br /><br /></li>
				<li>阅读 Yahoo! Exceptional Performance 团队起草的 <a href="http://developer.yahoo.com/performance/index.html#rules">高性能网站规则</a>。<br /><br /></li>
				<li>阅读 Martin Brown 的文章 “<a href="http://www.serverwatch.com/tutorials/article.php/3514866">Using HTTP Compression</a>”（ServerWatch，2005 年 6 月），了解有关 HTTP 压缩各方面的详细信息。<br /><br /></li>
				<li>了解 <a href="http://www.alistapart.com/articles/sprites/">CSS sprites</a> —— 它们是什么以及如何使用它们加快图像加载速度。<br /><br /></li>
				<li>Learn how to <a href="http://javascript-reference.info/speed-up-your-javascript-load-time.htm">加快 JavaScript 加载速度</a>。 <br /><br /></li>
				<li>阅读 Jesse Skinner 的 developerWorks 文章 “<a href="http://www.ibm.com/developerworks/cn/web/wa-aj-when">在应用程序中使用 Ajax 的时机</a>”。 <br /><br /></li>
				<li>了解与 <a href="http://www.gnu.org/software/gzip/">gzip 压缩库</a> 有关的更多信息。 <br /><br /></li>
				<li>
						<a href="http://www.ibm.com/developerworks/cn/web/">developerWorks Web 开发专区</a> 包含用于 Web 2.0 开发的大量工具和信息。<br /><br /></li>
				<li>
						<a href="http://www.ibm.com/developerworks/cn/offers/techbriefings/">developerWorks 技术活动和网络广播</a>：随时关注最新技术。<br /><br /></li>
				<li>
						<a href="http://www.ibm.com/developerworks/apps/SendTo?bookstore=safari">技术书店</a>：浏览与本文所述主题和其他技术主题相关的图书。<br /><br /></li>
		</ul>
		<br />
		<b>获得产品和技术</b>
		<br />
		<ul>
				<li>使用 <a href="http://www.crockford.com/javascript/jsmin.html">JSMin</a> 将您的 JavaScript 文件精简到极限。<br /><br /></li>
				<li>
						<a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> 是 Yahoo! 的 JavaScript 压缩器和 Yahoo! UI Library 的一部分。这个站点还提供了有关压缩代码的不同方面以及理想的代码如何淡化负面效应的大量读物。<br /><br /></li>
				<li>
						<a href="http://www.jslint.com/">JSLint</a> 可以帮助您识别糟糕的编码实践。<br /><br /></li>
				<li>
						<a href="http://getfirebug.com/">Firebug</a> 是一个 Firefox 插件，为您提供了广泛的开发工具。<br /><br /></li>
				<li>发现和下载 <a href="http://gears.google.com/">Google Gears</a>。<br /><br /></li>
				<li>
						<a href="http://developer.yahoo.com/yslow/">YSlow</a> 是 Yahoo! 开发的一个 Firebug 插件，用于分析您的页面并告诉您页面变慢的原因。<br /><br /></li>
		</ul>
		<br />
		<b>讨论</b>
		<br />
		<ul>
				<li>
						<a onmouseover="linkQueryAppend(this)" href="http://www.ibm.com/developerworks/blogs/">developerWorks 博客</a>：查看 developerWorks 博客并参与 <a onmouseover="linkQueryAppend(this)" href="http://www.ibm.com/developerworks/community">developerWorks 社区</a>。</li>
		</ul>
		<br />
		<br />
		<p>
				<a name="author">
						<span class="atitle">关于作者</span>
				</a>
		</p>
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td colspan="3">
										<img height="5" alt="" src="http://www.ibm.com/i/c.gif" width="100%" />
								</td>
						</tr>
						<tr valign="top" align="left">
								<td>
										<p>
										</p>
								</td>
								<td>
										<img height="5" alt="" src="http://www.ibm.com/i/c.gif" width="4" />
								</td>
								<td width="100%">
										<p>Marco Kotrotsos 是一名拥有 10 年构建软件系统经验的开发人员，他构建过的软件系统范围很广，从用于顶级保险公司的企业级应用程序，到用于刚起步的企业的 SMB 和 Web 应用程序的管理工具。Marco 是 Incredicorp 的创始人，这家公司主要帮助刚起步的企业和小型企业将他们的产品推向市场。他与语义 Web、AI、CSS3 和语义搜索等先进领域的技术专家合作。</p>
								</td>
						</tr>
				</tbody>
		</table><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6452.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-04-27 13:50 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/04/27/6452.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>iframe 根据里边的内容自适应高度</title><link>http://www.phpweblog.net/fuyongjie/archive/2009/04/23/6446.html</link><dc:creator>bestmost</dc:creator><author>bestmost</author><pubDate>Thu, 23 Apr 2009 05:51:00 GMT</pubDate><guid>http://www.phpweblog.net/fuyongjie/archive/2009/04/23/6446.html</guid><wfw:comment>http://www.phpweblog.net/fuyongjie/comments/6446.html</wfw:comment><comments>http://www.phpweblog.net/fuyongjie/archive/2009/04/23/6446.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fuyongjie/comments/commentRss/6446.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fuyongjie/services/trackbacks/6446.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">a href</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">http://www.baidu.com</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> target</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">'aa'</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">试试</span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">a</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">script type</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">text/javascript</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> <br /><img id="Codehighlighter1_110_578_Open_Image" onclick="this.style.display='none'; Codehighlighter1_110_578_Open_Text.style.display='none'; Codehighlighter1_110_578_Closed_Image.style.display='inline'; Codehighlighter1_110_578_Closed_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_110_578_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_110_578_Closed_Text.style.display='none'; Codehighlighter1_110_578_Open_Image.style.display='inline'; Codehighlighter1_110_578_Open_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> SetCwinHeight()</span>
				<span id="Codehighlighter1_110_578_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.phpweblog.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_110_578_Open_Text">
						<span style="COLOR: #000000">{ <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
						<span style="COLOR: #0000ff">var</span>
						<span style="COLOR: #000000"> bobo</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">document.getElementById(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">bobo</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">); </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">iframe id </span>
						<span style="COLOR: #008000">
								<br />
								<img id="Codehighlighter1_204_572_Open_Image" onclick="this.style.display='none'; Codehighlighter1_204_572_Open_Text.style.display='none'; Codehighlighter1_204_572_Closed_Image.style.display='inline'; Codehighlighter1_204_572_Closed_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_204_572_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_204_572_Closed_Text.style.display='none'; Codehighlighter1_204_572_Open_Image.style.display='inline'; Codehighlighter1_204_572_Open_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">                </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (document.getElementById)</span>
						<span id="Codehighlighter1_204_572_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.phpweblog.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_204_572_Open_Text">
								<span style="COLOR: #000000">{ <br /><img id="Codehighlighter1_238_565_Open_Image" onclick="this.style.display='none'; Codehighlighter1_238_565_Open_Text.style.display='none'; Codehighlighter1_238_565_Closed_Image.style.display='inline'; Codehighlighter1_238_565_Closed_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_238_565_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_238_565_Closed_Text.style.display='none'; Codehighlighter1_238_565_Open_Image.style.display='inline'; Codehighlighter1_238_565_Open_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                    </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (bobo </span>
								<span style="COLOR: #000000">&amp;&amp;</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">!</span>
								<span style="COLOR: #000000">window.opera)</span>
								<span id="Codehighlighter1_238_565_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.phpweblog.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_238_565_Open_Text">
										<span style="COLOR: #000000">{ <br /><img id="Codehighlighter1_314_385_Open_Image" onclick="this.style.display='none'; Codehighlighter1_314_385_Open_Text.style.display='none'; Codehighlighter1_314_385_Closed_Image.style.display='inline'; Codehighlighter1_314_385_Closed_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_314_385_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_314_385_Closed_Text.style.display='none'; Codehighlighter1_314_385_Open_Image.style.display='inline'; Codehighlighter1_314_385_Open_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                        </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (bobo.contentDocument </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> bobo.contentDocument.body.offsetHeight)</span>
										<span id="Codehighlighter1_314_385_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.phpweblog.net/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_314_385_Open_Text">
												<span style="COLOR: #000000">{ <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/InBlock.gif" align="top" />                            bobo.height </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> bobo.contentDocument.body.offsetHeight; <br /><img id="Codehighlighter1_443_507_Open_Image" onclick="this.style.display='none'; Codehighlighter1_443_507_Open_Text.style.display='none'; Codehighlighter1_443_507_Closed_Image.style.display='inline'; Codehighlighter1_443_507_Closed_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_443_507_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_443_507_Closed_Text.style.display='none'; Codehighlighter1_443_507_Open_Image.style.display='inline'; Codehighlighter1_443_507_Open_Text.style.display='inline';" src="http://www.phpweblog.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                        }</span>
										</span>
										<span style="COLOR: #0000ff">else</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000">(bobo.Document </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> bobo.Document.body.scrollHeight)</span>
										<span id="Codehighlighter1_443_507_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.phpweblog.net/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_443_507_Open_Text">
												<span style="COLOR: #000000">{ <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/InBlock.gif" align="top" />                            bobo.height </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> bobo.Document.body.scrollHeight; <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                        }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.phpweblog.net/images/OutliningIndicators/InBlock.gif" align="top" />                        bobo.height </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> parseInt(bobo.height)</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">20</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">px</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                    }</span>
								</span>
								<span style="COLOR: #000000"> <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
						</span>
						<span style="COLOR: #000000"> <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />            }</span>
				</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">script</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">iframe width</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">100%</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> name</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">aa</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">bobo</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> onload</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Javascript:SetCwinHeight()</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> height</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> frameborder</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> scrolling</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">no</span>
				<span style="COLOR: #000000">&gt;&lt;/</span>
				<span style="COLOR: #000000">iframe</span>
				<span style="COLOR: #000000">&gt;</span>
		</div><img src ="http://www.phpweblog.net/fuyongjie/aggbug/6446.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fuyongjie/" target="_blank">bestmost</a> 2009-04-23 13:51 <a href="http://www.phpweblog.net/fuyongjie/archive/2009/04/23/6446.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>