<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[5D Home]]></title> 
<link>http://www.5dhome.net/myblog/index.php</link> 
<description><![CDATA[PHP, Typo3 CMS, Typolight CMS, Javascript, Jquery, Windows, Linux, iphone]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[5D Home]]></copyright>
<item>
<link>http://www.5dhome.net/myblog/read.php?213</link>
<title><![CDATA[如何比较两个日期相差几天 ]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Sun, 13 Apr 2008 05:44:53 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?213</guid> 
<description>
<![CDATA[ 
	今天无意间点到某个有关php脚本的网站，看到如下一个脚本，标题为<br/><br/><span style="color: #FF4500;"><span style="font-size: 14px;">如何比较两个日期相差几天</span> </span><br/><br/>条条大路通罗马，对于程序也一样，主要的区别在于程序的执行效率，希望大家能更深入php，很多函数其实php自身都带着，下面的两个日期比较的php脚本，程序理念和最终的输出结果是一样的，都是围绕着将日期化成时间戳才进行比较，但是大家可以看出来一个strtotime函数省去了多少代码。<br/><br/>[codes=php]<br/>&lt;?php <br/>/*<br/>&nbsp;&nbsp;* 作者：不知道作者是谁<br/>&nbsp;&nbsp;* 日期：2008-4-13<br/>&nbsp;&nbsp;* 功能：计算两个日期的时间差<br/>&nbsp;&nbsp;* 备注：基本上没有修改程序代码，仅将书写规范了下，以及做了注释&nbsp;&nbsp;// 曼查罗<br/>&nbsp;&nbsp;*/<br/>&nbsp;&nbsp;<br/>// 定义要比较的两个日期<br/>$Date_1=&quot;2008-7-15&quot;;<br/>$Date_2=&quot;2006-7-14&quot;;&nbsp;&nbsp;<br/><br/>// 将日期化成数组，以便制作时间戳<br/>$Date_List_1=explode(&quot;-&quot;,$Date_1);&nbsp;&nbsp;<br/>$Date_List_2=explode(&quot;-&quot;,$Date_2);&nbsp;&nbsp;<br/><br/>// 制作时间戳<br/>$d1=mktime(0,0,0,$Date_List_1[1],$Date_List_1[2],$Date_List_1[0]);&nbsp;&nbsp;<br/>$d2=mktime(0,0,0,$Date_List_2[1],$Date_List_2[2],$Date_List_2[0]);&nbsp;&nbsp;<br/><br/>// 日期比较<br/>$Days=round(($d1-$d2)/3600/24);&nbsp;&nbsp;<br/><br/>// 输出结果<br/>echo &quot;$Days days&quot;;&nbsp;&nbsp;<br/>?&gt;<br/>[/codes]<br/><br/><br/>[codes=php]<br/>&lt;?php<br/>/*<br/>&nbsp;&nbsp;* 作者：曼查罗<br/>&nbsp;&nbsp;* 日期：2008-4-13<br/>&nbsp;&nbsp;* 功能：计算两个日期的时间差<br/>&nbsp;&nbsp;*/<br/><br/>// 用php自带函数strtotime对日期进行时间戳格式化<br/>$date1_ts = strtotime(&quot;2008-7-15&quot;);<br/>$date2_ts = strtotime(&quot;2006-7-14&quot;);<br/><br/>// 日期比较<br/>$days=round(($date1_ts-$date2_ts)/3600/24); <br/><br/>// 输出结果<br/>echo &quot;$days days&quot;;<br/>?&gt;<br/>[/codes]<br/><br/><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?194</link>
<title><![CDATA[PHP5下$_SERVER变量将不再受magic_quotes_gpc的保护]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Mon, 07 Jan 2008 03:00:33 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?194</guid> 
<description>
<![CDATA[ 
	在php5的环境中我们的$_SERVER变量将不再受magic_quotes_gpc的保护，至于程序该如何加强自己的安全性，还是那句话，加强程序自身的过滤机制吧，不要依赖于语言本身了!记得所有的输入都是有害的 :)<br/><br/>[codes=php]<br/>&lt;?php<br/>$magic_quotes_gpc = get_magic_quotes_gpc();<br/>@extract(daddslashes($_COOKIE));<br/>@extract(daddslashes($_POST));<br/>@extract(daddslashes($_GET));<br/>if(!$magic_quotes_gpc) &#123;<br/> $_FILES = daddslashes($_FILES);<br/>&#125;<br/>?&gt;<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?193</link>
<title><![CDATA[给图片添加文字(支持中文) // PHP函数]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Thu, 27 Dec 2007 08:25:09 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?193</guid> 
<description>
<![CDATA[ 
	[codes=php]<br/>&lt;?php<br/>// **************************************** // <br/>// 功能:给图片添加文字<br/>// 参数: $img 图片文件名 <br/>// $new_img 另存图片文件名,如果为空表示不另存图片 <br/>// $text 字符串内容 <br/>// text_size 字符串大小 <br/>// text_angle 字型串输出角度 <br/>// text_x 字符串输出 x 坐标 <br/>// text_y 字符串输出 y 坐标 <br/>// $text_font 字型文件名 <br/>// $r,$g,$b 字符串颜色RGB值 <br/>// **************************************** // <br/>function img_text($img, $new_img, $text, $text_size, $text_angle, $text_x, $text_y, $text_font, $r, $g, $b)&#123;<br/><br/>$text=iconv(&quot;gb2312&quot;,&quot;UTF-8&quot;,$text); <br/>Header(&quot;Content-type: image/gif&quot;); <br/>$im = @imagecreatefromstring(file_get_contents($img)) or die (&quot;打开图片失败!&quot;); <br/>$color = ImageColorAllocate($im, $r,$g,$b); <br/><br/>//ImageTTFText(int im, int size, int angle, int x, int y, int col, string fontfile, string text)： <br/>//本函数将 TTF (TrueType Fonts) 字型文字写入图片。 <br/>//参数: size 为字形的尺寸； <br/>// angle 为字型的角度，顺时针计算，0 度为水平(由左到右)，90 度则为由下到上的文字； <br/>// x,y 二参数为文字的坐标值 (原点为左上角)； <br/>// col 为字的颜色； <br/>// fontfile 为字型文件名称； <br/>// text 是字符串内容。 <br/>ImageTTFText($im, $text_size, $text_angle, $text_x, $text_y, $color, $text_font, $text); <br/><br/>if ($new_img==&quot;&quot;): <br/>ImageGif($im); // 不保存图片,只显示 <br/>else: <br/>ImageGif($im,$new_img); // 保存图片,但不显示 <br/>endif; <br/><br/>ImageDestroy($im); //结束图形，释放内存空间 <br/>&#125; &nbsp;<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?191</link>
<title><![CDATA[为什么点击浏览器的后退按钮后，所有字段的信息都被清空了？]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Thu, 27 Dec 2007 03:32:52 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?191</guid> 
<description>
<![CDATA[ 
	问：为什么我在点击浏览器的后退按钮后，所有字段的信息都被清空了？<br/><br/>答：这是由于你在你的表单提交页面中使用了 session_start 函数。该函数会强制当前页面不被缓存。解决办法为，在你的 Session_start 函数后加入 header(&quot;Cache-control: private&quot;); 注意在本行之前你的PHP程序不能有任何输出。<br/><br/>还有基于session的解决方法，在session_start前加上<br/>[codes=php]<br/>session_cache_limiter(&#039;nocache&#039;);// 清空表单<br/>session_cache_limiter(&#039;private&#039;); //不清空表单，只在session生效期间<br/>session_cache_limiter(&#039;public&#039;); //不清空表单，如同没使用session一般<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?190</link>
<title><![CDATA[PHP4 即将退出历史的舞台]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Thu, 27 Dec 2007 03:28:20 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?190</guid> 
<description>
<![CDATA[ 
	<br/>PHP官方团队在 php.net上 发布了一则公告：<br/><br/>Today it is exactly three years ago since PHP 5 has been released. In those three years it has seen many improvements over PHP 4. PHP 5 is fast, stable &amp; production-ready and as PHP 6 is on the way, PHP 4 will be discontinued.<br/><br/>The PHP development team hereby announces that support for PHP 4 will continue until the end of this year only. After 2007-12-31 there will be no more releases of PHP 4.4. We will continue to make critical security fixes available on a case-by-case basis until 2008-08-08. Please use the rest of this year to make your application suitable to run on PHP 5.<br/><br/>简译一下：<br/><br/>PHP5发布已经三年了，在这三年中PHP5有了很大改进，已经在很多方面超越了PHP4。PHP5快速、稳定并且已经做好了用于正式开发的准备。另外，PHP6的开发也在顺利进行。所以PHP4即将退出历史舞台。<br/><br/>PHP4的开发将维持到2007年12月31日，之后就不再有PHP4.4的新版本发布。phpe.net将继续为PHP4提供安全方面的补丁，直到2008年8月8日。请利用今年的剩余时间来让您的项目更适合运行于PHP5环境。<br/><br/><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?189</link>
<title><![CDATA[使用PHP的日期与时间函数提高开发技巧]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Thu, 20 Dec 2007 06:04:59 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?189</guid> 
<description>
<![CDATA[ 
	使用PHP的日期与时间函数提高开发技巧<br /><br /> <table border="1" cellspacing="0" cellpadding="0" bordercolor="#999999"><tbody><tr><td width="182"><p class="style3" align="center">功能</p></td> &nbsp; &nbsp; <td width="189"><p class="style3" align="center">说明</p></td> &nbsp; &nbsp; <td width="189"><p class="style3" align="center">实例</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p class="style2">checkdate($month, $date, $year)</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">如果应用的值构成一个有效日期，则该函数返回为真。例如，对于错误日期2005年2月31日，此函数返回为假。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>在日期用于计算或保存在数据库中之前，可用此函数检查日期并使日期生效。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns false</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo checkdate(2,30,2005) ? </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">&quot;valid&quot; : </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">&quot;invalid&quot;;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns true</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo checkdate(4,6,2010) ? &quot;valid&quot; : </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">&quot;invalid&quot;;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"><p class="style2">getdate($ts)</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">在没有自变量的情况下，该函数以结合数组的方式返回当前日期与时间。数组中的每个元素代表日期/时间值中的一个特定组成部分。可向函数提交可选的时间标签自变量，以获得与时间标签对应的日期/时间值。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>应用此函数来获得一系列离散的，容易分离的日期/时间值。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns timestamp for </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">13:15:23 </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">7-Jun-2006</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo mktime(13,15,23,6,7,2006);</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"><p class="style2">mktime($hour, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$minute, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$second, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$month, $day, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$year)</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">此函数的作用与<em>getdate()</em>的作用相反：它由一系列的日期与时间值生成一个UNIX时间标签（GMT时间1970年1月1日到现在消逝的秒数）。不用自变量时，它生成当前时间的UNIX时间标签。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>用此函数获得即时时间的UNIX时间标签。这种时间标签通常用于许多数据库与程序语言中。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns timestamp for </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">13:15:23 </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">7-Jun-2006</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo mktime(13,15,23,6,7,2006);</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">date($format, $ts)</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">此函数将UNIX时间标签格式化成一个可人为阅读的日期字符串。它是PHP日期/时间API中功能最为强大的函数，可用在一系列的修正值中，将整数时间标签转变为所需的字符串格式。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>为显示格式化时间或日期时，应用此函数。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// format current date</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns &quot;13-Sep-2005 01:16 PM&quot;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo date(&quot;d-M-Y h:i A&quot;, mktime</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">());</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">strtotime ($str)</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">此函数将可人为阅读的英文日期/时间字符串转换成UNIX时间标签。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>应用此函数将非标准化的日期/时间字符串转换成标准、兼容的UNIX时间标签。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns 13-Sep-05</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo date(&quot;d-M-y&quot;, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">strtotime(&quot;today&quot;));</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns 14-Sep-05</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo date(&quot;d-M-y&quot;, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">strtotime(&quot;tomorrow&quot;));</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns 16-Sep-05</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo date(&quot;d-M-y&quot;, strtotime(&quot;today +3 </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">days&quot;));</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p class="style2">strftime ($format, $ts)</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">如前面的setlocale()函数定义的那样，此函数将UNIX时间标签格式化成适用于当前环境的日期字符串。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>应用此函数建立与当前环境兼容的日期字符串。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// set locale to France (on </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">Windows)</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">setlocale(LC_TIME, &quot;fra_fra&quot;);</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// format month/day names</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// as per locale setting</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns &quot;septembre&quot; and </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">&quot;mardi&quot;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo strftime(&quot;Month: %B &quot;);</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo strftime(&quot;Day: %A &quot;);</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"><p class="style2">microtime()</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">此函数返回GMT时间1970年1月1日到现在所消逝的秒数与微秒数。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>在基准特定的代码块，准确测量它的执行时间时应用此函数。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// get starting value</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$start = microtime();</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// run some code</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">for ($x=0; $x&lt;1000; $x++) &#123;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">牋?$null = $x * $x;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">&#125;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// get ending value</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$end = microtime();</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// calculate time taken for </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">code </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">execution</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo &quot;Elapsed time: &quot; . ($end - </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"> </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$start) .&quot; sec&quot;;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"><p class="style2">gmmktime</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">($hour, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$minute, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$second, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$month, $day, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">$year)</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">此函数由一系列用GMT时间表示的日期与时间值生成一个UNIX时间标签。不用自变量时，它生成一个当前GMT即时时间的UNIX时间标签。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>用此函数来获得GMT即时时间的UNIX时间标签。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns timestamp for </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">12:25:23 </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">9-Jul-2006</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo gmmktime</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">(12,25,23,7,9,2006);</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p class="style2">gmdate ($format, $ts)</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">此函数将UNIX时间标签格式化成可人为阅读的日期字符串。此日期字符串以GMT（非当地时间）表示。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>用GMT表示时间标签时应用此函数。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// format current date into GMT</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// returns &quot;13-Sep-2005 08:32 </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">AM&quot;</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">echo gmdate(&quot;d-M-Y h:i A&quot;, </p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">mktime());</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td> &nbsp; </tr> &nbsp; <tr> &nbsp; &nbsp; <td width="182" valign="top"><p class="style2">date_default_</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">timezone_set</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">($tz)and</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">date_default_</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">timezone_get()</p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">此函数此后所有的日期/时间函数调用设定并恢复默认的时区。</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><strong><em>注</em></strong><em>：此函数仅在PHP 5.1+中有效。</em><em> </em></p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2"><em>此函数是一个方便的捷径，可为以后的时间操作设定时区。</em></p></td> &nbsp; &nbsp; <td width="189" valign="top"><p class="style2">&lt;?php</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">// set timezone to UTC</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">date_default_timezone_set</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">('UTC');</p> &nbsp; &nbsp; &nbsp; &nbsp; <p class="style2">?&gt;</p></td></tr></tbody></table><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?188</link>
<title><![CDATA[[转载]PHP常用正则表达式收集]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Thu, 20 Dec 2007 05:58:18 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?188</guid> 
<description>
<![CDATA[ 
	<strong>匹配中文字符的正则表达式：</strong><span style="color: #FF4500;"> [&#92;u4e00-&#92;u9fa5]</span><br/>评注：匹配中文还真是个头疼的事，有了这个表达式就好办了<br/><br/><strong>匹配双字节字符(包括汉字在内)：</strong><span style="color: #FF4500;">[^&#92;x00-&#92;xff]</span><br/>评注：可以用来计算字符串的长度（一个双字节字符长度计2，ASCII字符计1）<br/><br/><strong>匹配空白行的正则表达式：</strong><span style="color: #FF4500;">&#92;n&#92;s*&#92;r</span><br/>评注：可以用来删除空白行<br/><br/><strong>匹配HTML标记的正则表达式：</strong><span style="color: #FF4500;">&lt;(&#92;S*?)[^&gt;]*&gt;.*?&lt;/&#92;1&gt;&#124;&lt;.*? /&gt;</span><br/>评注：网上流传的版本太糟糕，上面这个也仅仅能匹配部分，对于复杂的嵌套标记依旧无能为力<br/><br/><strong>匹配首尾空白字符的正则表达式：</strong><span style="color: #FF4500;">^&#92;s*&#124;&#92;s*$</span><br/>评注：可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等)，非常有用的表达式<br/><br/><strong>匹配Email地址的正则表达式：</strong><span style="color: #FF4500;">&#92;w+([-+.]&#92;w+)*@&#92;w+([-.]&#92;w+)*&#92;.&#92;w+([-.]&#92;w+)*</span><br/>评注：表单验证时很实用<br/><br/><strong>匹配网址URL的正则表达式：</strong><span style="color: #FF4500;">[a-zA-z]+://[^&#92;s]*</span><br/>评注：网上流传的版本功能很有限，上面这个基本可以满足需求<br/><br/><strong>匹配帐号是否合法(字母开头，允许5-16字节，允许字母数字下划线)：</strong><span style="color: #FF4500;">^[a-zA-Z][a-zA-Z0-9_]&#123;4,15&#125;$</span><br/>评注：表单验证时很实用<br/><br/><strong>匹配国内电话号码：</strong><span style="color: #FF4500;">&#92;d&#123;3&#125;-&#92;d&#123;8&#125;&#124;&#92;d&#123;4&#125;-&#92;d&#123;7&#125;</span><br/>评注：匹配形式如 0511-4405222 或 021-87888822<br/><br/><strong>匹配腾讯QQ号：</strong><span style="color: #FF4500;">[1-9][0-9]&#123;4,&#125;</span><br/>评注：腾讯QQ号从10000开始<br/><br/><strong>匹配中国邮政编码：</strong><span style="color: #FF4500;">[1-9]&#92;d&#123;5&#125;(?!&#92;d)</span><br/>评注：中国邮政编码为6位数字<br/><br/><strong>匹配身份证：</strong><span style="color: #FF4500;">&#92;d&#123;15&#125;&#124;&#92;d&#123;18&#125;</span><br/>评注：中国的身份证为15位或18位<br/><br/><strong>匹配ip地址：</strong><span style="color: #FF4500;">&#92;d+&#92;.&#92;d+&#92;.&#92;d+&#92;.&#92;d+</span><br/>评注：提取ip地址时有用<br/><br/><strong>匹配特定数字：</strong><br/>^[1-9]&#92;d*$　 　 //匹配正整数<br/>^-[1-9]&#92;d*$ 　 //匹配负整数<br/>^-?[1-9]&#92;d*$　　 //匹配整数<br/>^[1-9]&#92;d*&#124;0$　 //匹配非负整数（正整数 + 0）<br/>^-[1-9]&#92;d*&#124;0$　　 //匹配非正整数（负整数 + 0）<br/>^[1-9]&#92;d*&#92;.&#92;d*&#124;0&#92;.&#92;d*[1-9]&#92;d*$　　 //匹配正浮点数<br/>^-([1-9]&#92;d*&#92;.&#92;d*&#124;0&#92;.&#92;d*[1-9]&#92;d*)$　 //匹配负浮点数<br/>^-?([1-9]&#92;d*&#92;.&#92;d*&#124;0&#92;.&#92;d*[1-9]&#92;d*&#124;0?&#92;.0+&#124;0)$　 //匹配浮点数<br/>^[1-9]&#92;d*&#92;.&#92;d*&#124;0&#92;.&#92;d*[1-9]&#92;d*&#124;0?&#92;.0+&#124;0$　　 //匹配非负浮点数（正浮点数 + 0）<br/>^(-([1-9]&#92;d*&#92;.&#92;d*&#124;0&#92;.&#92;d*[1-9]&#92;d*))&#124;0?&#92;.0+&#124;0$　　//匹配非正浮点数（负浮点数 + 0）<br/>评注：处理大量数据时有用，具体应用时注意修正<br/><br/><strong>匹配特定字符串：</strong><br/>^[A-Za-z]+$　　//匹配由26个英文字母组成的字符串<br/>^[A-Z]+$　　//匹配由26个英文字母的大写组成的字符串<br/>^[a-z]+$　　//匹配由26个英文字母的小写组成的字符串<br/>^[A-Za-z0-9]+$　　//匹配由数字和26个英文字母组成的字符串<br/>^&#92;w+$　　//匹配由数字、26个英文字母或者下划线组成的字符串<br/>评注：最基本也是最常用的一些表达式<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?186</link>
<title><![CDATA[PHP Session的问题集锦以及解决方案]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Wed, 19 Dec 2007 16:01:34 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?186</guid> 
<description>
<![CDATA[ 
	PHP的session功能，一直为许多的初学者为难。就连有些老手，有时都被搞得莫名其妙。本文，将这些问题，做一个简单的汇总，以便大家查阅。<br/><br/><strong>1. 错误提示</strong><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Warning: Cannot send session cookie - headers already sent<br/>Warning: Cannot send session cache limiter - headers already sent<br/></div></div><br/><br/>分析及解决办法<br/>这一类问题，的原因是你在程序中使用session_start()时，之前已经有实际的html内容输出了。或许你说，我没有啊，我只不过是echo或 print一条消息了。很抱歉，你的echo或print语句所产生的输出，就是实际的html内容输出。解决此类问题的办法是，将你的 session_start()调到程序的第一行。<br/><br/><strong>2. 错误提示</strong><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Warning: open(F:/689&#92;&#92;php&#92;&#92;sessiondata&#92;&#92;sess_66a39376b873f4daecf239891edc98b5, O_RDWR) failed<br/></div></div><br/><br/>分析及解决方法<br/>出现这样的错误语句一般是因为你的php.ini中关于session.save_path一项没有设置好，解决的方法是将session.save_path和session.cookie_path 设置置为<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>session_save_path = c:&#92;&#92;temp<br/>session.cookie_path = c:&#92;&#92;temp<br/></div></div><br/><br/>然后在c:&#92;&#92;目录下建立一个temp目录，即可<br/><br/><strong>3. 错误提示</strong><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Warning: Trying to destroy uninitialized session in<br/></div></div><br/><br/>分析及解决方法<br/>出类这样的提示，一般情况都是你直接调session_destroy()函数造成的。很多的朋友认为session_destroy()函数可以独立的运行，其实不然。解决的方法是在你调session_destroy()函数之前，要用session_start()开启session的功能。<br/><br/><strong>4.问题:怎么获得当前session的id值呢？</strong><br/>最简单的方法是:<br/>echo SID;<br/>你会发现的。<br/><br/><strong>5. 问题:我的程序，在调用header函数之前没有任何的输出，虽然我include了一个config.php文件，但在config.php文件中也没有任何的输出，为什么session还是会报出与问题1同样的错误呢，是不是因为我在header之前用了session_start()的缘故呢?</strong><br/><br/>答: 或许你确实认真的检查了你的php程序，在引用header()之前确实也没有任何的输出，并且在你的include文件中也没有任何的输出！但是你是否用光标键在? &gt;这个PHP代码结束语句后移动检查呢？那么你会发现在? &gt;这个后面，有一个空行或几个空格，你删除了这几个空行或空格，那么问题就解决了。<br/>注：此问题，会出PHP4.1.2中，更高版本，没有测试过。<br/><br/><strong>6.问:用session做登录主页面后，其它页面怎么用session限制登录</strong><br/>答：最简单的方法是<br/><br/>[codes=php]<br/>session_start();<br/>if(!session_registered(&#039;login&#039;) ││ $login != true) &#123;<br/>echo &quot;你没有登陆&quot;;<br/>exit;<br/>&#125;<br/>[/codes]<br/><br/><strong>7.问题:我用session_register()注册了session变量，可是当我用header或用javs script的重定向语句，那么在一下页面中，我却访问不到session所注册的变量值。请问如何解决？</strong><br/><br/><br/>问题的程序片段：<br/><br/>[codes=php]<br/>&lt;?php<br/>session_start();<br/>$ok = &#039;love you&#039;;<br/>session_register(&#039;ok&#039;);<br/>header(&quot;location : next.php&quot;);<br/>? &gt;<br/>[/codes]<br/><br/>next.php<br/>[codes=php]<br/>&lt;?php<br/>session_start();<br/>echo $ok;<br/>? &gt;<br/>[/codes]<br/><br/>解决的方法：<br/>当你用header函数或window.location这样的功能后，你上一个页面所注册的session变量，就会容易的丢失，关于这个问题的原因，至今仍没有一个详细的回答。<br/>不过有解决的方法。如下所示<br/><br/>[codes=php]<br/>header(&quot;Location: next.php&quot; .&quot;?&quot; . SID);<br/>[/codes]<br/><br/>在跳转到下一页面的时候，将session的当前id做为一个参数，传到后一个页面。<br/><br/><strong>8.session如何传数组</strong><br/><br/>[codes=php]<br/>session_register(&#039;data&#039;);<br/>$data=array(1,2,3,4);<br/>[/codes]<br/><br/>方法是先注册后赋值<br/><br/><strong>9.问题：我是不是可以用像$HTTP_GET_VARS[&#039;**&#039;]方式来访问session值呢？</strong><br/><br/>回答：可以，你可以使用如下global数组来访问session，以加强网页的安全性<br/>$HTTP_SESSION_VARS<br/>$_SESSION<br/>例程:<br/><br/>[codes=php]<br/>&lt;?php<br/>session_start();<br/>$username = &#039;stangly.wrong&#039;;<br/>session_register(&#039;username&#039;);<br/><br/>echo $HTTP_SESSION_VARS[&#039;username&#039;];<br/>echo &#039;&lt;br&gt;&#039;;<br/>echo $_SESSION[&#039;username&#039;];<br/>? &gt;<br/>[/codes]<br/><br/>请参照此例程修改符合您自己的程序。<br/><br/><strong>问题10: session_unregister() 和 session_destroy() 有何区别？</strong><br/>session_unregister ()函数主要作用是注消当前的一个session变量。不过要注意的是，如果你用$HTTP_SESSION_VARS或$_SESSION在当前页面中引用过session变量，那么你可能需要和unset()配合 来注消session变量。<br/>而session_destroy()是清除当前的session环境。意思就是说，当你用session_destroy()函数后，那么你就不可能再用session_is_registered ()来检测session的变量了。但是需要注意的是他不能清除global中的session或使用了session cookie的中的session.所以在用session_destroy之前，最好不要用$HTTP_SESSION_VARS $_SESSION来访问session.<br/><br/>例程：<br/><br/>[codes=php]<br/>if(isset($_COOKIE[session_name()])) &#123;<br/>session_start();<br/>session_destroy();<br/>unset($_COOKIE[session_name()]);<br/>&#125; <br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?176</link>
<title><![CDATA[解决php+odbc读取access数据库时，在读取memo字段没有读取完整的问题]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Wed, 26 Sep 2007 12:24:11 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?176</guid> 
<description>
<![CDATA[ 
	[codes=php]<br/>&lt;?php<br/>/*<br/> &nbsp;* Samsun Xu<br/> &nbsp;* 2007-09-26<br/> &nbsp;* PHP+ODBC调用MS Access数据库<br/> &nbsp;* 问题：在读取memo字段的时候出现问题，字段读取出来了，但是没有读取完整<br/> &nbsp;* 解决：odbc_binmode，odbc_longreadlen函数解决问题的关键<br/> &nbsp;*/<br/><br/>$dsn=&quot;DRIVER=&#123;Microsoft Access Driver (*.mdb)&#125;; DBQ=数据库路径&quot;; // 例如：E:&#92;&#92;www&#92;&#92;database&#92;&#92;test.mdb<br/>$connection= odbc_connect($dsn, &quot;用户名&quot;, &quot;密码&quot;); // 如果没有用户名和密码的话，请至空<br/>$query = &quot;SELECT * FROM news WHERE id=88&quot;; // 这里假设我们要读取news表中的id=88的这条纪录<br/><br/>// ---------------------------------------------------------------------------------------------------------------------<br/>// 方法2<br/>// 读取单个字段<br/>// ---------------------------------------------------------------------------------------------------------------------<br/>$queryexe = odbc_do($connection, $query);<br/>odbc_queryexe_setting($queryexe);<br/>while(odbc_fetch_row($queryexe)) &#123;<br/>&nbsp;&nbsp;echo odbc_result($queryexe,&quot;maintext&quot;); // 读取news表中字段名为maintext的内容，也可以odbc_result($queryexe,6)来读取，数字6表示该字段在表中位于第6列<br/>&#125;<br/><br/><br/>echo &quot;&lt;hr&gt;&quot;; // 分割线<br/><br/><br/>// ---------------------------------------------------------------------------------------------------------------------<br/>// 方法2<br/>// 读取整个纪录<br/>// ---------------------------------------------------------------------------------------------------------------------<br/>$queryexe = odbc_do($connection, $query);<br/>odbc_queryexe_setting($queryexe);<br/>$row = odbc_fetch_assoc($queryexe);<br/>print_r($row);<br/><br/><br/><br/><br/>// ---------------------------------------------------------------------------------------------------------------------<br/>// 函数<br/>// ---------------------------------------------------------------------------------------------------------------------<br/><br/>/* <br/> &nbsp;* 读取大字段的设定 <br/> &nbsp;* 1638400 -&gt; 1.6MB 左右<br/> &nbsp;*/ <br/>function odbc_queryexe_setting($rs,$length=1638400)&#123;<br/>&nbsp;&nbsp;odbc_binmode($rs, ODBC_BINMODE_PASSTHRU); <br/>&nbsp;&nbsp;odbc_longreadlen($rs, $length); <br/>&#125;<br/><br/>/* <br/> &nbsp;* &nbsp;读取单条纪录到数组<br/> &nbsp;*/<br/>function odbc_fetch_assoc($rs)&#123;<br/>&nbsp;&nbsp;if (odbc_fetch_row($rs))&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$line=array(&quot;odbc_affected_rows&quot;=&gt;odbc_num_rows($rs));<br/>&nbsp;&nbsp;&nbsp;&nbsp;for($f=1;$f&lt;=odbc_num_fields($rs);$f++)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fn=odbc_field_name($rs,$f);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fct=odbc_result($rs,$fn);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$newline=array($fn =&gt; $fct);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$line=array_merge($line,$newline);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;return $line;<br/>&nbsp;&nbsp;&#125; else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;return false;<br/>&nbsp;&nbsp;&#125;<br/>&#125;<br/>?&gt;<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=database" rel="tag">database</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=access" rel="tag">access</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?167</link>
<title><![CDATA[windows+apache2+php+mysql+mssql 配置]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Thu, 30 Aug 2007 16:33:49 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?167</guid> 
<description>
<![CDATA[ 
	<span style="font-size: 18px;">超级简单的windows php环境配置</span><br/><br/><strong><span style="color: #FF4500;">============================== 下载 ==================================</span></strong><br/>apache: http://httpd.apache.org/download.cgi&nbsp;&nbsp;&nbsp;&nbsp; //我用的是2.0.59Win32 Binary (MSI Installer)的版本，2.2.4的版本改的比较多，以后再研究<br/>php: http://www.php.net/downloads.php&nbsp;&nbsp;&nbsp;&nbsp; //到php官方网下载最新的php原码包.zip的格式，我用的是PHP 5.2.3 zip package<br/>mysql: http://dev.mysql.com/downloads/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //到mysql官方网下载mysqlwindows安装包，我用的是4.1的版本，感觉比较稳定点<br/><br/>详细步骤请点击进入<br/><br/><br/><strong><span style="color: #FF4500;">============================== 安装==================================</span></strong><br/><strong>#### apache 安装 ####</strong><br/>双击安装文件，一路next，要输入的时候，输入从上到下localhost, localhost, 34n.sam@gmail.com，选择d:&#92;为安装目录，安装完后d:&#92;盘会出现apache2目录，为什么装在d:&#92;？？习惯了，不喜欢装c:&#92;盘，呵呵。<br/><br/><br/><strong>#### mysql 安装 ####</strong><br/>双击安装包，一路next，到时候输入root账号密码即可，安装在d:&#92;根目录，为什么装载d:&#92;盘，这把可不是个人习惯，而是强烈建议大家装在d:&#92;盘，因为系统崩溃了，重装系统，还能在d:&#92;mysql&#92;data下面找到数据库。<br/><br/><br/><strong>#### php 配置 ####</strong><br/>为什么php我没有选安装包而选了.zip的包，因为.zip的包比安装包更灵活点，配置起来也不麻烦。解压zip包，把文件家的名字改成php，放在d:&#92;根目录，这样3个环境都装在d:&#92;盘了，管理起来也方便点。<br/><br/>复制<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>libmcrypt.dll<br/>libmysql.dll<br/>ntwdblib.dll<br/>php5ts.dll<br/></div></div><br/>到c:&#92;winnt&#92;system32&#92;或者c:&#92;windows&#92;system32&#92;目录下。<br/><br/>复制php目录下的php.ini-dist到c:&#92;winnt&#92;并重命名为php.ini，打开php.ini，修改<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>1. 找到extension_dir这行，改成extension_dir = &quot;d:/php/ext&quot;<br/>2. 找到;extension，会有一堆extentsion，前面的;是注释的意思，我启用的是常用的一些库，如果大家认识这些库的话，自己开启有用的即可，这里要注意一点的是如果要开启exif必须mbstring的支持，而且要把extension=php_mbstring.dll放在extension=php_exif.dll的前面，不然会出错。<br/>extension=php_mbstring.dll<br/>extension=php_mcrypt.dll //加密的时候会用到<br/>extension=php_bz2.dll<br/>extension=php_curl.dll<br/>extension=php_exif.dll<br/>extension=php_fdf.dll<br/>extension=php_filepro.dll<br/>extension=php_gd2.dll //图形处理的时候会用到<br/>extension=php_mime_magic.dll<br/>extension=php_ming.dll<br/>extension=php_mssql.dll&nbsp;&nbsp;//微软的ms sql server支持<br/>extension=php_mysql.dll&nbsp;&nbsp;//mysql支持<br/>extension=php_sockets.dll<br/><br/><br/>3. 找到post_max_size，改成post_max_size = 32M 支持最大的提交数据<br/>4. 找到upload_max_filesize，改成upload_max_filesize = 32M 支持最大的上传文件<br/></div></div><br/><br/><br/><strong>#### apache 配置 ####</strong><br/>打开d:&#92;apache2&#92;conf&#92;httpd.conf文件<br/>找到LoadModule，在最后一行LoadModule加上下面两行<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>LoadModule php5_module &quot;d:/php/php5apache2_2.dll&quot;<br/>AddType application/x-httpd-php .php<br/></div></div><br/><br/><br/><strong><span style="color: #FF4500;">============================== 调试php环境 ==================================</span></strong><br/>1. 在d:&#92;盘根目录下新建一个www的目录，以后做项目的时候放里面，呵呵对d:&#92;情有独钟<br/>2. 打开d:&#92;apache2&#92;conf&#92;httpd.conf文件<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>1) 找到DocumentRoot &quot;D:/apche2/htdocs&quot;，改成DocumentRoot &quot;D:/www&quot;<br/>2) 找到&lt;Directory &quot;D:/apche2/htdocs&quot;&gt;，改成&lt;Directory &quot;D:/www&quot;&gt;<br/></div></div><br/>3. 重启apache2，不要告诉我你不懂的重启apache，那你可以拿块豆腐去撞了。<br/>4. 在d:&#92;www下面新建一个文件，info.php编辑内容为<br/>[codes=php]<br/>&lt;?php<br/>phpinfo();<br/>?&gt;<br/>[/codes]<br/>5. 打开IE浏览器，输入http://localhost/info.php，如果你刚才按照我说的步骤一步步下来的话，应该可以看到php的配置环境以及载入的模块介绍，为php呐喊，为php加油，oh yeah~~<br/><br/><br/><br/><br/><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=windows" rel="tag">windows</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=apache" rel="tag">apache</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?162</link>
<title><![CDATA[再次加速你的PHP程序]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Fri, 13 Jul 2007 13:04:39 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?162</guid> 
<description>
<![CDATA[ 
	PHP的运行速度是非常的理想的，尤其是Zend引擎的加速之后。但是PHP仍然有加速的可能<br/><br/><strong>所有的一切都始于如何优化PHP的编译</strong><br/><br/>尝试使用针对CPU型号的特殊编译参数 -msse -mmmx -mfpmath=sse<br/>在编译的时候添加 -03参数<br/>编译的时候调节CPU的参数 -march -mcpu Use Caution<br/>尽量只编译你需要的模块，避免无用的扩展加载<br/>对于很少使用的扩展模块，应该编译成共享模式，便于在运行的时候动态加载<br/>也许有些时候--disable-all 会是你的好朋友<br/>把PHP静态编译到Apache可以提速20％<br/><br/># PHP<br/>./configure --with-apache=/path/to/apache_sourcePHPChina<br/><br/># Apache<br/>./configure --activate-module=src/modules/php4/libphp4.a<br/><br/><br/><strong>优化你的PHP配置文件</strong><br/>确认你的 register_globals 配置为disabled<br/>禁用 magic_quotes_* 选项<br/>关闭 expose_php<br/>关闭 register_argc_argv<br/>关闭 always_populate_raw_post_data<br/><br/><br/><strong>Apache服务器的优化配置</strong><br/>使用高配置<br/>MaxClients 设置为你的服务器可以承受的2/5<br/>MaxRequestsPerChild 理想情况是0 (不限)，但是实际上都设置为一个较的一个值<br/><br/><br/><strong>优化文件访问</strong><br/>DirectoryIndex 文件列表尽可能简短<br/>无论如何禁止 .htaccess 文件的 AllowOverridenone<br/>使用 FollowSymLinks 简化文件访问处理<br/>避免使用 mod_rewrite 或者更复杂的操作<br/>如果日志非必须的话就禁用<br/>如果必须使用日志，那么请记录到一个文件中去，并且在分析过后清除<br/><br/><br/><strong>消除昂贵的系统呼叫</strong><br/>不要开启 ExtendedStatus<br/>在允许和禁止规则的时候使用IP而不要使用域名<br/>不要启用 HostnameLookups<br/>保持 ServerSignature 关闭<br/>设置KeepAlive 为较小的一个值<br/>动态和静态的内容分离<br/>提高硬盘性能参数<br/>使用output_buffering 优化PHP到Apache的交互<br/>增加Apache的 SendBufferSize 大小<br/><br/><br/><strong>提高缓存执行</strong><br/>使用PHP代码缓存机制<br/>Turck MMCache 停止开发<br/>P0APC较慢，优化不够<br/>Zend Cache优化性能好，但付费<br/>Cube PHP Accelerator 免费但不开源<br/>如果可以使用Zlib压缩<br/><br/><br/><strong>减少输出数据</strong><br/>用CSS替换HTML<br/>压缩HTML页面<br/>使用Sessions管理<br/>优化你的SQL指令<br/><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=linux" rel="tag">linux</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=%25E4%25BC%2598%25E5%258C%2596" rel="tag">优化</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?161</link>
<title><![CDATA[php连接sql server数据库实例]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Fri, 13 Jul 2007 12:42:38 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?161</guid> 
<description>
<![CDATA[ 
	[codes=php]<br/>&lt;?php<br/><br/>/**<br/> * @author samsun<br/> * @copyright 2007<br/> * php使用mssql库，连接sql server数据库实例<br/> */<br/><br/><br/> &nbsp;$server=&#039;ip地址或服务器名&#039;;<br/> &nbsp;$username=&#039;数据库用户名&#039;;<br/> &nbsp;$password=&#039;数据库密码&#039;;<br/> &nbsp;$database=&#039;数据库名&#039;;<br/><br/> &nbsp;$conn=mssql_connect($server,$username,$password)<br/> &nbsp; &nbsp; &nbsp; &nbsp;or die(&quot;Couldn&#039;t connect to SQL Server on $server&quot;);<br/> &nbsp;$db=mssql_select_db($database) or die(&quot;Couldn&#039;t open database $database&quot;);<br/><br/>?&gt;<br/>[/codes]<br/><br/>[codes=php]<br/>&lt;?php<br/><br/>/**<br/> * @author samsun<br/> * @copyright 2007<br/> * php使用ODBC连接sql server数据库实例<br/> */<br/><br/> &nbsp;$server=&#039;ip地址或服务器名&#039;;<br/> &nbsp;$username=&#039;数据库用户名&#039;;<br/> &nbsp;$password=&#039;数据库密码&#039;;<br/> &nbsp;$database=&#039;数据库名&#039;;<br/><br/> &nbsp;$connstr = &quot;Driver=&#123;SQL Server&#125;;Server=$server;Database=$database&quot;;<br/><br/> &nbsp;if ( !odbc_connect($connstr,$username,$password,SQL_CUR_USE_ODBC))&#123;<br/> &nbsp;echo &quot;Couldn&#039;t connect to SQL Server on $server&quot;;<br/> &nbsp;&#125;else&#123;<br/> &nbsp;echo &quot;Connect successfully!&lt;br&gt;&quot;;<br/> &nbsp;&#125;<br/>?&gt;<br/>[/codes]<br/><br/><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=mssql" rel="tag">mssql</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=odbc" rel="tag">odbc</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?155</link>
<title><![CDATA[PHP通用检测函数集]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Tue, 26 Jun 2007 09:22:55 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?155</guid> 
<description>
<![CDATA[ 
	// ※CheckMoney($C_Money) 检查数据是否是99999.99格式<br/>// ※CheckEmailAddr($C_mailaddr) 判断是否为有效邮件地址<br/>// ※CheckWebAddr($C_weburl) 判断是否为有效网址<br/>// ※CheckEmpty($C_char) 判断字符串是否为空<br/>// ※CheckLengthBetween($C_char, $I_len1, $I_len2=100) 判断是否为指定长度内字符串<br/>// ※CheckUser($C_user) 判断是否为合法用户名<br/>// ※CheckPassword($C_passwd) 判断是否为合法用户密码<br/>// ※CheckTelephone($C_telephone) 判断是否为合法电话号码<br/>// ※CheckValueBetween($N_var, $N_val1, $N_val2) 判断是否是某一范围内的合法值<br/>// ※CheckPost($C_post) 判断是否为合法邮编（固定长度）<br/>// ※CheckExtendName($C_filename,$A_extend) 判断上传文件的扩展名<br/>// ※CheckImageSize($ImageFileName,$LimitSize) 检验上传图片的大小<br/>// ※AlertExit($C_alert,$I_goback=0) 非法操作警告并退出<br/>// ※Alert($C_alert,$I_goback=0) 非法操作警告<br/>// ※ReplaceSpacialChar($C_char) 特殊字符替换函数<br/>// ※ExchangeMoney($N_money) 资金转换函数<br/>// ※WindowLocation($C_url,$C_get=&quot;&quot;,$C_getOther=&quot;&quot;) PHP中的window.location函数<br/>//-----------------------------------------------------------------------------------<br/><br/>[codes=php]<br/>&lt;?php <br/>// 函数名：CheckMoney($C_Money) &nbsp; &nbsp; <br/>// 作 用：检查数据是否是99999.99格式 &nbsp; &nbsp; <br/>// 参 数：$C_Money（待检测的数字） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckMoney($C_Money) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if (!ereg(&quot;^[0-9][.][0-9]$&quot;, $C_Money)) return false; &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckEmailAddr($C_mailaddr) &nbsp; &nbsp; <br/>// 作 用：判断是否为有效邮件地址 &nbsp; &nbsp; <br/>// 参 数：$C_mailaddr（待检测的邮件地址） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckEmailAddr($C_mailaddr) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if (!eregi(&quot;^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$&quot;, &nbsp; &nbsp; <br/>$C_mailaddr)) &nbsp; &nbsp; <br/>//(!ereg(&quot;^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*$&quot;, &nbsp; &nbsp; <br/>$c_mailaddr)) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>return false; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckWebAddr($C_weburl) &nbsp; &nbsp; <br/>// 作 用：判断是否为有效网址 &nbsp; &nbsp; <br/>// 参 数：$C_weburl（待检测的网址） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckWebAddr($C_weburl) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if (!ereg(&quot;^http://[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*$&quot;, $C_weburl)) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>return false; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckEmpty($C_char) &nbsp; &nbsp; <br/>// 作 用：判断字符串是否为空 &nbsp; &nbsp; <br/>// 参 数：$C_char（待检测的字符串） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckEmptyString($C_char) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if (!is_string($C_char)) return false; //是否是字符串类型 &nbsp; &nbsp; <br/>if (empty($C_char)) return false; //是否已设定 &nbsp; &nbsp; <br/>if ($C_char==&#039;&#039;) return false; //是否为空 &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckLengthBetween($C_char, $I_len1, $I_len2=100) &nbsp; &nbsp; <br/>// 作 用：判断是否为指定长度内字符串 &nbsp; &nbsp; <br/>// 参 数：$C_char（待检测的字符串） &nbsp; &nbsp; <br/>// $I_len1 （目标字符串长度的下限） &nbsp; &nbsp; <br/>// $I_len2 （目标字符串长度的上限） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckLengthBetween($C_cahr, $I_len1, $I_len2=100) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$C_cahr = trim($C_cahr); &nbsp; &nbsp; <br/>if (strlen($C_cahr) &lt; $I_len1) return false; &nbsp; &nbsp; <br/>if (strlen($C_cahr) &gt; $I_len2) return false; &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckUser($C_user) &nbsp; &nbsp; <br/>// 作 用：判断是否为合法用户名 &nbsp; &nbsp; <br/>// 参 数：$C_user（待检测的用户名） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckUser($C_user) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if (!CheckLengthBetween($C_user, 4, 20)) return false; //宽度检验 &nbsp; &nbsp; <br/>if (!ereg(&quot;^[_a-zA-Z0-9]*$&quot;, $C_user)) return false; //特殊字符检验 &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>?&gt;<br/>[/codes]<br/><br/>[codes=php]<br/>&lt;?php <br/>// 函数名：CheckPassword($C_passwd) &nbsp; &nbsp; <br/>// 作 用：判断是否为合法用户密码 &nbsp; &nbsp; <br/>// 参 数：$C_passwd（待检测的密码） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckPassword($C_passwd) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if (!CheckLengthBetween($C_passwd, 4, 20)) return false; //宽度检测 &nbsp; &nbsp; <br/>if (!ereg(&quot;^[_a-zA-Z0-9]*$&quot;, $C_passwd)) return false; //特殊字符检测 &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckTelephone($C_telephone) &nbsp; &nbsp; <br/>// 作 用：判断是否为合法电话号码 &nbsp; &nbsp; <br/>// 参 数：$C_telephone（待检测的电话号码） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckTelephone($C_telephone) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if (!ereg(&quot;^[+]?[0-9]+([xX-][0-9]+)*$&quot;, $C_telephone)) return false; &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckValueBetween($N_var, $N_val1, $N_val2) &nbsp; &nbsp; <br/>// 作 用：判断是否是某一范围内的合法值 &nbsp; &nbsp; <br/>// 参 数：$N_var 待检测的值 &nbsp; &nbsp; <br/>// $N_var1 待检测值的上限 &nbsp; &nbsp; <br/>// $N_var2 待检测值的下限 &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckValueBetween($N_var, $N_val1, $N_val2) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if ($N_var &lt; $N_var1 ││ $N_var &gt; $N_var2) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>return false; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/> <br/>&#125; &nbsp; &nbsp; <br/> <br/>?&gt;<br/>[/codes] <br/>[codes=php]<br/>&lt;?php <br/>// 函数名：CheckPost($C_post) &nbsp; &nbsp; <br/>// 作 用：判断是否为合法邮编（固定长度） &nbsp; &nbsp; <br/>// 参 数：$C_post（待check的邮政编码） &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckPost($C_post) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$C_post=trim($C_post); &nbsp; &nbsp; <br/>if (strlen($C_post) == 6) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if(!ereg(&quot;^[+]?[_0-9]*$&quot;,$C_post)) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>return true;; &nbsp; &nbsp; <br/>&#125;else &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>return false; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>&#125;else &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>return false;; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>&#125;<br/><br/><br/><br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckExtendName($C_filename,$A_extend) &nbsp; &nbsp; <br/>// 作 用：上传文件的扩展名判断 &nbsp; &nbsp; <br/>// 参 数：$C_filename 上传的文件名 &nbsp; &nbsp; <br/>// $A_extend 要求的扩展名 &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckExtendName($C_filename,$A_extend) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if(strlen(trim($C_filename)) &lt; 5) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>return 0; //返回0表示没上传图片 &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>$lastdot = strrpos($C_filename, &quot;.&quot;); //取出.最后出现的位置 &nbsp; &nbsp; <br/>$extended = substr($C_filename, $lastdot+1); //取出扩展名 &nbsp; &nbsp; <br/> <br/> <br/>for($i=0;$i&#123; &nbsp; &nbsp; <br/>if (trim(strtolower($extended)) == trim(strtolower($A_extend[$i]))) //转换大 &nbsp; &nbsp; <br/>小写并检测 &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$flag=1; //加成功标志 &nbsp; &nbsp; <br/>$i=count($A_extend); //检测到了便停止检测 &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/>if($flag&lt;&gt;1) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>for($j=0;$j&#123; &nbsp; &nbsp; <br/>$alarm .= $A_extend[$j].&quot; &quot;; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>AlertExit(&#039;只能上传&#039;.$alarm.&#039;文件！而你上传的是&#039;.$extended.&#039;类型的文件&#039;); &nbsp; &nbsp; <br/>return -1; //返回-1表示上传图片的类型不符 &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/>return 1; //返回1表示图片的类型符合要求 &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：CheckImageSize($ImageFileName,$LimitSize) &nbsp; &nbsp; <br/>// 作 用：检验上传图片的大小 &nbsp; &nbsp; <br/>// 参 数：$ImageFileName 上传的图片名 &nbsp; &nbsp; <br/>// $LimitSize 要求的尺寸 &nbsp; &nbsp; <br/>// 返回值：布尔值 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function CheckImageSize($ImageFileName,$LimitSize) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$size=GetImageSize($ImageFileName); &nbsp; &nbsp; <br/>if ($size[0]&gt;$LimitSize[0] ││ $size[1]&gt;$LimitSize[1]) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>AlertExit(&#039;图片尺寸过大&#039;); &nbsp; &nbsp; <br/>return false; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>return true; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：Alert($C_alert,$I_goback=0) &nbsp; &nbsp; <br/>// 作 用：非法操作警告 &nbsp; &nbsp; <br/>// 参 数：$C_alert（提示的错误信息） &nbsp; &nbsp; <br/>// $I_goback（返回到那一页） &nbsp; &nbsp; <br/>// 返回值：字符串 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function Alert($C_alert,$I_goback=0) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if($I_goback&lt;&gt;0) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>echo &quot; &quot;; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>else &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>echo &quot; &quot;; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>?&gt; <br/>[/codes]<br/>[codes=php]<br/>&lt;?php <br/>// 函数名：AlertExit($C_alert,$I_goback=0) &nbsp; &nbsp; <br/>// 作 用：非法操作警告 &nbsp; &nbsp; <br/>// 参 数：$C_alert（提示的错误信息） &nbsp; &nbsp; <br/>// $I_goback（返回到那一页） &nbsp; &nbsp; <br/>// 返回值：字符串 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function AlertExit($C_alert,$I_goback=0) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if($I_goback&lt;&gt;0) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>echo &quot; &quot;; &nbsp; &nbsp; <br/>exit; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>else &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>echo &quot; &quot;; &nbsp; &nbsp; <br/>exit; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：ReplaceSpacialChar($C_char) &nbsp; &nbsp; <br/>// 作 用：特殊字符替换函数 &nbsp; &nbsp; <br/>// 参 数：$C_char（待替换的字符串） &nbsp; &nbsp; <br/>// 返回值：字符串 &nbsp; &nbsp; <br/>// 备 注：这个函数有问题，需要测试才能使用 <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function ReplaceSpecialChar($C_char) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$C_char=HTMLSpecialChars($C_char); //将特殊字元转成 HTML 格式。 &nbsp; &nbsp; <br/>$C_char=nl2br($C_char); //将回车替换为 &nbsp; &nbsp; <br/> <br/> <br/>$C_char=str_replace(&quot; &quot;,&quot; &quot;,$C_char); //替换空格为 &nbsp; &nbsp; <br/>return $C_char; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：ExchangeMoney($N_money) &nbsp; &nbsp; <br/>// 作 用：资金转换函数 &nbsp; &nbsp; <br/>// 参 数：$N_money（待转换的金额数字） &nbsp; &nbsp; <br/>// 返回值：字符串 &nbsp; &nbsp; <br/>// 备 注：本函数示例：$char=ExchangeMoney(5645132.3155) ==&gt; $char=&#039;￥5,645,132.31&#039; &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function ExchangeMoney($N_money) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$A_tmp=explode(&quot;.&quot;,$N_money ); //将数字按小数点分成两部分，并存入数组$A_tmp &nbsp; &nbsp; <br/>$I_len=strlen($A_tmp[0]); //测出小数点前面位数的宽度 &nbsp; &nbsp; <br/> <br/> <br/>if($I_len%3==0) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$I_step=$I_len/3; //如前面位数的宽度mod 3 = 0 ,可按，分成$I_step 部分 &nbsp; &nbsp; <br/>&#125;else &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$step=($len-$len%3)/3+1; //如前面位数的宽度mod 3 != 0 ,可按，分成$I_step 部分+1 &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/>$C_cur=&quot;&quot;; &nbsp; &nbsp; <br/>//对小数点以前的金额数字进行转换 &nbsp; &nbsp; <br/>while($I_len&lt;&gt;0) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$I_step--; &nbsp; &nbsp; <br/> <br/>if($I_step==0) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$C_cur .= substr($A_tmp[0],0,$I_len-($I_step)*3); &nbsp; &nbsp; <br/>&#125;else &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$C_cur .= substr($A_tmp[0],0,$I_len-($I_step)*3).&quot;,&quot;; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/>$A_tmp[0]=substr($A_tmp[0],$I_len-($I_step)*3); &nbsp; &nbsp; <br/>$I_len=strlen($A_tmp[0]); &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/>//对小数点后面的金额的进行转换 &nbsp; &nbsp; <br/>if($A_tmp[1]==&quot;&quot;) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$C_cur .= &quot;.00&quot;; &nbsp; &nbsp; <br/>&#125;else &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$I_len=strlen($A_tmp[1]); &nbsp; &nbsp; <br/>if($I_len&lt;2) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$C_cur .= &quot;.&quot;.$A_tmp[1].&quot;0&quot;; &nbsp; &nbsp; <br/>&#125;else &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>$C_cur .= &quot;.&quot;.substr($A_tmp[1],0,2); &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/>//加上人民币符号并传出 &nbsp; &nbsp; <br/>$C_cur=&quot;￥&quot;.$C_cur; &nbsp; &nbsp; <br/>return $C_cur; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/> <br/> <br/> <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/>// 函数名：WindowLocation($C_url,$C_get=&quot;&quot;,$C_getOther=&quot;&quot;) &nbsp; &nbsp; <br/>// 作 用：PHP中的window.location函数 &nbsp; &nbsp; <br/>// 参 数：$C_url 转向窗口的URL &nbsp; &nbsp; <br/>// $C_get GET方法参数 &nbsp; &nbsp; <br/>// $C_getOther GET方法的其他参数 &nbsp; &nbsp; <br/>// 返回值: 字符串 &nbsp; &nbsp; <br/>// 备 注：无 &nbsp; &nbsp; <br/>//----------------------------------------------------------------------------------- &nbsp; &nbsp; <br/> <br/>function WindowLocation($C_url,$C_get=&quot;&quot;,$C_getOther=&quot;&quot;) &nbsp; &nbsp; <br/>&#123; &nbsp; &nbsp; <br/>if($C_get == &quot;&quot; &amp;&amp; $C_getOther == &quot;&quot;) &nbsp; &nbsp; <br/>if($C_get == &quot;&quot; &amp;&amp; $C_getOther &lt;&gt; &quot;&quot;)&#123;$C_target=&quot;&quot;window.location=&#039;$C_url? &nbsp; &nbsp; <br/>$C_getOther=&#039;+this.value&quot;&quot;;&#125; &nbsp; &nbsp; <br/>if($C_get &lt;&gt; &quot;&quot; &amp;&amp; $C_getOther == &quot;&quot;)&#123;$C_target=&quot;&quot;window.location=&#039;$C_url? &nbsp; &nbsp; <br/>$C_get&#039;&quot;&quot;;&#125; &nbsp; &nbsp; <br/>if($C_get &lt;&gt; &quot;&quot; &amp;&amp; $C_getOther &lt;&gt; &quot;&quot;)&#123;$C_target=&quot;&quot;window.location=&#039;$C_url? &nbsp; &nbsp; <br/>$C_get&amp;$C_getOther=&#039;+this.value&quot;&quot;;&#125; &nbsp; &nbsp; <br/>return $C_target; &nbsp; &nbsp; <br/>&#125; &nbsp; &nbsp; <br/>?&gt;<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?154</link>
<title><![CDATA[PHP Session丢失问题解决]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Mon, 25 Jun 2007 01:54:14 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?154</guid> 
<description>
<![CDATA[ 
	<strong><span style="color: #FF4500;">正常设置session, 但是在某些windows服务器始终有session丢失情况</span></strong><br/>[codes=php]<br/>&lt;?php<br/>/* <br/> * session1.php<br/> * 正常设置session, 但是在某些windows服务器造成session丢失<br/> */<br/><br/>session_start();<br/>$_SESSION[&#039;test&#039;] = &quot;Hello World!&quot;;<br/>header(&quot;location:session2.php&quot;);<br/>?&gt;<br/>[/codes]<br/><br/>[codes=php]<br/>&lt;?php<br/>/* <br/> * session2.php<br/> * 正常设置session, 但是在某些windows服务器造成session丢失<br/> */<br/><br/>session_start();<br/>echo $_SESSION[&#039;test&#039;];<br/>?&gt;<br/>[/codes]<br/><br/><br/><strong><span style="color: #FF4500;">解决session丢失情况</span></strong><br/>在session_start();前加上session_id(SID);<br/><br/>[codes=php]<br/>&lt;?php<br/>/* <br/> * session1.php<br/> */<br/>session_id(SID);<br/>session_start();<br/>$_SESSION[&#039;test&#039;] = &quot;Hello World!&quot;;<br/>header(&quot;location:session2.php&quot;);<br/>?&gt;<br/>[/codes]<br/><br/>[codes=php]<br/>&lt;?php<br/>/* <br/> * session2.php<br/> */<br/>session_id(SID);<br/>session_start();<br/>echo $_SESSION[&#039;test&#039;];<br/>?&gt;<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?143</link>
<title><![CDATA[上传、图片生成缩略图出错（内存过小）]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Wed, 23 May 2007 03:15:55 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?143</guid> 
<description>
<![CDATA[ 
	Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 92160 bytes) in /xxx.php on line 123。<br/><br/><strong>办法1：</strong><br/>在php程序中加入<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>ini_set(”upload_max_filesize”, “20M”);<br/>ini_set(”memory_limit”, “32M”);<br/>ini_set(”post_max_size”, “24M”);<br/></div></div><br/><strong>办法2：</strong><br/>在php程序中加入<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">ini_set(”memory_limit”, “-1″);</div></div><br/><strong>办法3：</strong><br/>修改php.ini文件中的php memory设置，将其改大，此方法不适用于虚拟主机的用户，因为无法修改服务器的配置。<br/><br/><br/><br/><br/><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?139</link>
<title><![CDATA[php读取文本文件]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Tue, 15 May 2007 09:01:44 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?139</guid> 
<description>
<![CDATA[ 
	[codes=php]<br/>&lt;?php<br/>// open file<br/>$file_handle = fopen(&quot;file.txt&quot;, &quot;r&quot;);<br/><br/>// read line by line<br/>while (!feof($file_handle)) &#123;<br/>&nbsp;&nbsp;$line&nbsp;&nbsp;=&nbsp;&nbsp;fgets($file_handle);<br/>&nbsp;&nbsp;echo $line;<br/>&#125;<br/><br/>// close file<br/>fclose($file_handle);<br/>?&gt;<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?123</link>
<title><![CDATA[UTF8下mailto subject body中文显示问题]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Wed, 18 Apr 2007 07:02:47 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?123</guid> 
<description>
<![CDATA[ 
	UTF8页面下，用mailto转邮件客户端，此时会出现中文乱码<br/><br/>本人用的是php作服务器端脚本，解决的办法<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>在php程序里用 urlencode(&quot;邮件的主题&quot;) ,将中文进行网页加密, 然后就可以了<br/></div></div><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=html" rel="tag">html</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?115</link>
<title><![CDATA[Windows下IIS/Apache+PHP+MySQL+Zend]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Tue, 20 Mar 2007 04:05:59 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?115</guid> 
<description>
<![CDATA[ 
	<span style="color: #FF4500;"><strong>一、软件准备：</strong></span><br/><br/>Apache（2.0.52）： http://www.skycn.com/soft/1218.html<br/><br/>PHP（4.3.9）： http://www.php.net/downloads.php<br/><br/>MySQL（4.1.7）： http://dev.mysql.com/downloads/<br/><br/>Zend Optimizer（2.5.5）：http://www.zend.com/store/products/zend-optimizer.php<br/><br/>phpMyAdmin（2.6.0）： http://www.skycn.com/soft/10687.html<br/><br/>假设 C:&#92; 为你现在所使用操作系统的系统盘，如果你目前操作系统不是安装在 C:&#92; ，请自行修改。<br/><br/><br/><br/><span style="color: #FF4500;"><strong>二、安装 PHP ：</strong></span><br/><br/>（1）、下载后得到 php-4.3.9-Win32.zip ，解压至 C:&#92;PHP（这个路径可以随意，不过下面要是用到这个路径，请相应修改）；<br/><br/>（2）、进入 C:&#92;PHP ，将 php.ini-dist 复制一份放到 C:&#92;WINNT（ Windows 2003 下为 C:&#92;Windows ）内，改名为 php.ini ，然后用记事本打开，利用记事本的查找功能搜索 extension_dir = &quot;./&quot; ，并将其路径指到你的 PHP 目录下的 extensions 目录，比如：extension_dir = &quot;C:&#92;PHP&#92;extensions&quot; ；再搜索 register_globals = Off ，将 Off 改成 On ；如果你想让 PHP 支持更多功能模块，请按照下面的步骤去做，如果不想的话，直接保存关闭 php.ini 即可.<br/><br/>PHP 支持的模块很多，搜索：<br/><br/>;Windows Extensions<br/>;Note that MySQL and ODBC support is now built in, so no dll is needed for it.<br/>;<br/><br/>下面所列的就是 PHP 预支持的扩展模块，默认情况下都用分号在前面注释掉了，如果你想 PHP 支持某个模块，请将前面的“;”去掉即可。如果安装完毕后测试时，弹出不支持 xxx.dll 模块的话，直接将前面分号再加上去，保存后重启 Web 服务器就可以了。<br/><br/>（3）、把 C:&#92;PHP&#92;php4ts.dll 和 C:&#92;PHP&#92;dlls 目录下的所有文件复制粘贴到 C:&#92;WINNT&#92;system32&#92;（ Windows 2003 下为 C:&#92;Windows&#92;system32 ）内；<br/><br/>（4）、配置 IIS 使其支持 PHP ：<br/><br/>首先必须确定系统中已经正确安装 IIS ，如果没有安装，需要先安装 IIS ，安装步骤如下：<br/><br/>&lt;a&gt; Windows 2000 下的 IIS 安装：<br/><br/>用 Administrator 帐号登陆系统，将 Windows 2000 安装光盘插入光盘驱动器，进入“控制面板”点击“添加/删除程序”，再点击左侧的“添加/删除 Windows 组件”，在弹出的窗口中选择“Internet 信息服务（IIS）”，点下面的“详细信息”按钮，选择组件，以下组件是必须的：“Internet 服务管理器”、“World Wide Web 服务器”和“公用文件”，确定安装。<br/><br/>安装完毕后，在“控制面板”的“管理工具”里打开“服务”，检查“IIS Admin Service”和“World Wide Web Publishing Service”两项服务，如果没有启动，将其启动即可。<br/><br/>&lt;b&gt; Windows 2003 下的 IIS 安装：<br/><br/>由于 Windows 2003 的 IIS 6.0 集成在应用程序服务器中，因此安装应用程序服务器就会默认安装 IIS 6.0 ，在“开始”菜单中点击“配置您的服务器”，在打开的“配置您的服务器向导”里左侧选择“应用程序服务器（IIS，ASP.NET）”，单击“下一步”出现“应用程序服务器选项”，你可以选择和应用程序服务器一起安装的组件，默认全选即可，单击“下一步”，出现“选择总结界面”，提示了本次安装中的选项，配置程序将自动按照“选择总结”中的选项进行安装和配置。<br/><br/>打开浏览器，输入：http://localhost/，看到成功页面后进行下面的操作：<br/><br/>PHP 支持 CGI 和 ISAPI 两种安装模式，推荐使用 ISAPI 模式。<br/><br/>&lt;a&gt;、CGI 模式安装步骤：<br/><br/>在“控制面板”的“管理工具”中选择“Internet 服务管理器”，打开 IIS 后停止服务，然后在左侧“默认Web站点”上单击右键选择“属性”，在打开的“默认 Web 站点属性”窗口的“主目录”标签里找到并点击“配置”按钮，在弹出的“应用程序配置”窗口中找到并点击“添加”按钮，在弹出的窗口中新增一个扩展名映射，扩展名为 .php ，单击“浏览”将可执行文件指向 php.exe 所在路径，如：C:&#92;PHP&#92;php.exe ，然后一路确定即可。如果还想支持诸如 .php3 ，.phtml 等扩展名的 PHP 文件，可以重复“添加”步骤。<br/><br/>再打开“默认 Web 站点属性”窗口的“文档”标签，找到并点击“添加”按钮，向默认的 Web 站点启动文档列表中添加 index.php 项。您可以将 index.php 升到最高优先级，这样，访问站点时就会首先自动寻找并打开 index.php 文档。<br/><br/>确定 Web 目录的应用程序设置和执行许可中选择为纯脚本，然后关闭 Internet 信息服务管理器，在命令提示符中执行如下命令：<br/><br/>net stop w3svc<br/>net stop iisadmin<br/>net start w3svc<br/><br/>打开浏览器，输入：http://localhost/，看到成功页面后，在 IIS 根目录下新建一个 phpinfo.php ，内容如下：<br/><br/>&lt;?php<br/>phpinfo();<br/>?&gt;<br/><br/>打开浏览器，输入：http://localhost/phpinfo.php，将显示当前服务器所支持 PHP 的全部信息，可以看到 Server API的模式为：CGI 。<br/><br/>&lt;b&gt;、ISAPI 模式安装步骤：<br/><br/>在“控制面板”的“管理工具”中选择“Internet 服务管理器”，打开 IIS 后停止服务，然后在左侧“默认Web站点”上单击右键选择“属性”，在打开的“默认 Web 站点属性”窗口的“ISAPI 筛选器”标签里找到并点击“添加”按钮，在弹出的“筛选器属性”窗口中的“筛选器名称”栏中输入：PHP ，再将可执行文件指向 php4isapi.dll 所在路径，如：C:&#92;PHP&#92;sapi&#92;php4isapi.dll 。<br/><br/>打开“默认 Web 站点属性”窗口的“主目录”标签，找到并点击“配置”按钮，在弹出的“应用程序配置”窗口中找到并点击“添加”按钮，在弹出的窗口中新增一个扩展名映射，扩展名为 .php ，单击“浏览”将可执行文件指向 php4isapi.dll 所在路径，如：C:&#92;PHP&#92;sapi&#92;php4isapi.dll ，然后一路确定即可。如果还想支持诸如 .php3 ，.phtml 等扩展名的 PHP 文件，可以重复“添加”步骤。<br/><br/>再打开“默认 Web 站点属性”窗口的“文档”标签，找到并点击“添加”按钮，向默认的 Web 站点启动文档列表中添加 index.php 项。您可以将 index.php 升到最高优先级，这样，访问站点时就会首先自动寻找并打开 index.php 文档。<br/><br/>确定 Web 目录的应用程序设置和执行许可中选择为纯脚本，然后关闭 Internet 信息服务管理器，在命令提示符中执行如下命令：<br/><br/>net stop w3svc<br/>net stop iisadmin<br/>net start w3svc<br/><br/>打开浏览器，输入：http://localhost/，看到成功页面后，在 IIS 根目录下新建一个 phpinfo.php ，内容如下：<br/><br/>&lt;?php<br/>phpinfo();<br/>?&gt;<br/><br/>打开浏览器，输入：http://localhost/phpinfo.php，将显示当前服务器所支持 PHP 的全部信息，可以看到 Server API的模式为：ISAPI 。<br/><br/>（5）、配置 Apache 使其支持 PHP ：<br/><br/>一般下载后得到的是一个 .exe 文件，直接双击安装，过程中需设置一下服务器名，如设置为： localhost ，假设装在 C:&#92; 。<br/><br/>1、以 apache 模块安装 PHP （推荐）：<br/><br/>打开 C:&#92;Apache&#92;Apache2&#92;conf&#92;httpd.conf ，在最后添加如下代码：<br/><br/><br/>LoadModule php4_module &quot;C:/php4/sapi/php4apache2.dll&quot;<br/>AddType application/x-httpd-php .php<br/><br/><br/><br/>查找 DirectoryIndex ，在其后面添加 index.php ，保存后关闭文件，Restart Apache 。<br/><br/>打开浏览器，输入：http://localhost/，看到成功页面后，在 C:&#92;Apache&#92;Apache2&#92;htdocs 下新建一个 phpinfo.php ，内容如下：<br/><br/>&lt;?php<br/>phpinfo();<br/>?&gt;<br/><br/>打开浏览器，输入：http://localhost/phpinfo.php，将显示当前服务器所支持 PHP 的全部信息，可以看到 Server API的模式为：Apache2 handler 。<br/><br/>2、以 CGI 模式安装 PHP ：<br/><br/><br/>ScriptAlias /php4/ &quot;C:/php4/&quot;<br/>Action application/x-httpd-php4 &quot;/php4/php.exe&quot;<br/>AddType application/x-httpd-php4 .php<br/><br/><br/><br/>查找 DirectoryIndex ，在其后面添加 index.php ，保存后关闭文件，Restart Apache 。<br/><br/>打开浏览器，输入：http://localhost/，看到成功页面后，在 C:&#92;Apache&#92;Apache2&#92;htdocs 下新建一个 phpinfo.php ，内容如下：<br/><br/>&lt;?php<br/>phpinfo();<br/>?&gt;<br/><br/>打开浏览器，输入：http://localhost/phpinfo.php，将显示当前服务器所支持 PHP 的全部信息，可以看到 Server API的模式为：CGI 。<br/><br/><span style="color: #FF4500;"><strong>三、安装 MySQL ：</strong></span><br/><br/>如果你下载的是 Windows Essentials (x86) ，将得到 mysql-4.1.7-essential-win.exe ,直接双击安装即可。安装过程中会提示你是不是立即进行配置，选择否即可完成安装。安装完毕后，在“开始”菜单的“运行”中输入：C:&#92;MySQL&#92; bin&#92;mysqld-nt -install ，运行成功之后再输入：net mysql start ，将会启动 MySQL 服务；如果你还想较详细的配置 MySQL ，就请进入 C:&#92;MySQL&#92;bin 目录，运行 MySQLInstanceConfig.exe ，按提示操作即可。<br/><br/>如果你下载的是 Windows (x86) ，解压后双击执行 Setup.exe 即可，步骤同上。<br/><br/>如果你下载的是 Without installer (unzip in C:&#92;) ，直接解压到 C:&#92;MySQL ，在“开始”菜单的“运行”中输入： C:&#92;MySQL&#92;bin&#92;mysqld-nt.exe ，运行成功之后再输入：net mysql start ，即可启动 MySQL 服务。<br/><span style="color: #FF4500;"><br/><strong>四、安装 Zend Optimizer ：</strong></span><br/><br/>下载后得到 ZendOptimizer-2.5.5-Windows-i386.exe ，直接双击安装即可，安装过程要你选择 Web Server 时，选择 IIS ，然后提示你是否 Restart Web Server，选择是，完成安装之前提示是否备份 php.ini ，点确定后安装完成。<br/><br/>Zend Optimizer 的安装向导会自动根据你的选择来修改 php.ini 帮助你启动这个引擎。下面简单介绍一下 Zend Optimizer 的配置选项。以下为安装完成后 php.ini 里的默认配置代码（分号后面的内容为注释）：<br/><br/>[Zend]<br/>zend_optimizer.optimization_level=15<br/>;优化程度，这里定义启动多少个优化过程，默认值是 15 ，表示同时开启 10 个优化过程中的 1-4 ，我们可以将这个值改为 1023 ，表示开启全部10个优化过程。<br/><br/>zend_extension_ts=&quot;C:&#92;Zend&#92;lib&#92;ZendExtensionManager.dll&quot;<br/>;Zend Optimizer 模块在硬盘上的安装路径。<br/><br/>zend_extension_manager.optimizer_ts=&quot;C:&#92;Zend&#92;lib&#92;Optimizer-2.5.5&quot;<br/>;优化器所在目录，默认无须修改。<br/><br/><span style="color: #FF4500;"><strong>五、安装 phpMyAdmin：</strong></span><br/><br/>下载得到 phpMyAdmin-2.6.0.zip ，将其解压到 IIS 根目录，找到并打开 config.inc.php ，做以下修改：<br/><br/>搜索 $cfg[&#039;PmaAbsoluteUri&#039;] ，将其设置为 phpMyAdmin 目录路径，如：http://localhost/phpMyAdmin/ ；<br/><br/>搜索 $cfg[&#039;DefaultLang&#039;] ，将其设置为 zh-gb2312 ；<br/><br/>搜索 $cfg[&#039;DefaultCharset&#039;] ，将其设置为 gb2312 ；<br/><br/>打开浏览器，输入：http://localhost/phpMyAdmin/ ，若 IIS 和 MySQL 均已启动，phpMyAdmin 默认无须密码即可浏览数据库内容。<br/><br/>phpMyAdmin 的具体功能，请慢慢熟悉，这里不再赘述。 <br/><br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=windows" rel="tag">windows</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=apache" rel="tag">apache</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?108</link>
<title><![CDATA[中文字符串截取函数，在utf－8下也可正常截取]]></title> 
<author>luye &lt;&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Fri, 12 Jan 2007 02:16:48 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?108</guid> 
<description>
<![CDATA[ 
	[codes=php]<br/>function intercept_str ($fStr, $fStart, $fLen, $fCode = &quot;&quot;) &#123;<br/> &nbsp; &nbsp;switch ($fCode) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;case &quot;UTF-8&quot; :<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;preg_match_all(&quot;/[&#92;x01-&#92;x7f]&#124;[&#92;xc2-&#92;xdf][&#92;x80-&#92;xbf]&#124;&#92;xe0[&#92;xa0-&#92;xbf][&#92;x80-&#92;xbf]&#124;[&#92;xe1-&#92;xef]<br/>[&#92;x80-&#92;xbf][&#92;x80-&#92;xbf]&#124;&#92;xf0[&#92;x90-&#92;xbf][&#92;x80-&#92;xbf][&#92;x80-&#92;xbf]&#124;[&#92;xf1-&#92;xf7][&#92;x80-&#92;xbf][&#92;x80-&#92;xbf]<br/>[&#92;x80-&#92;xbf]/&quot;, $fStr, $ar); &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(func_num_args() &gt;= 3) &#123; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (count($ar[0])&gt;$fLen) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return join(&quot;&quot;,array_slice($ar[0],$fStart,$fLen)).&quot;...&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return join(&quot;&quot;,array_slice($ar[0],$fStart,$fLen));<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125; else &#123; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return join(&quot;&quot;,array_slice($ar[0],$fStart));<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br/> &nbsp; &nbsp; &nbsp; &nbsp;default:<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$fStart = $fStart*2;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$fLen &nbsp; = $fLen*2;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$strlen = strlen($fStr);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for ( $i = 0; $i &lt; $strlen; $i++ ) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( $i &gt;= $fStart &amp;&amp; $i &lt; ( $fStart+$fLen ) ) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( ord(substr($fStr, $i, 1)) &gt; 129 ) $tmpstr .= substr($fStr, $i, 2);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else $tmpstr .= substr($fStr, $i, 1);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( ord(substr($fStr, $i, 1)) &gt; 129 ) $i++;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( strlen($tmpstr) &lt; $strlen ) $tmpstr .= &quot;...&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Return $tmpstr;<br/> &nbsp; &nbsp;&#125;<br/>&#125;<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.5dhome.net/myblog/read.php?85</link>
<title><![CDATA[对于数据库防注入的解决办法]]></title> 
<author>曼查罗 &lt;34n.sam@gmail.com&gt;</author>
<category><![CDATA[php]]></category>
<pubDate>Sun, 12 Nov 2006 13:42:50 +0000</pubDate> 
<guid>http://www.5dhome.net/myblog/read.php?85</guid> 
<description>
<![CDATA[ 
	对于数据库防注入, 统一处理下$_POST和$_GET<br/><br/>[codes=php]<br/>$_POST = sql_injection($_POST);<br/><br/>$_GET = sql_injection($_GET);<br/><br/>function sql_injection($content)<br/>&#123;<br/><br/> &nbsp;if (!get_magic_quotes_gpc()) &#123;<br/> &nbsp;<br/> &nbsp; &nbsp;if (is_array($content)) &#123;<br/> &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp;foreach ($content as $key=&gt;$value) &#123;<br/> &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp;$content[$key] = addslashes($value);<br/> &nbsp; &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp;&#125; else &#123;<br/> &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp;addslashes($content);<br/> &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp;&#125;<br/> &nbsp;&#125;<br/> &nbsp;<br/> &nbsp;return $content;<br/> &nbsp;<br/>&#125;<br/>[/codes]<br/>Tags - <a href="http://www.5dhome.net/myblog/tag.php?tag=php" rel="tag">php</a> , <a href="http://www.5dhome.net/myblog/tag.php?tag=%25E6%2595%25B0%25E6%258D%25AE%25E5%25BA%2593" rel="tag">数据库</a>
]]>
</description>
</item>
</channel>
</rss>