<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>EricBess WebHome » Eric</title>
	
	<link>http://www.ericbess.com/ericblog</link>
	<description>Thinking only without action will be nothing</description>
	<lastBuildDate>Fri, 11 Sep 2009 11:49:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ericbess-eric" type="application/rss+xml" /><feedburner:emailServiceId>ericbess-eric</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>炒股大赛，奖品：100万现金，奔驰，液晶电视…</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/JwR5GQRkk70/</link>
		<comments>http://www.ericbess.com/ericblog/2009/09/11/%e6%8a%84%e8%82%a1%e5%a4%a7%e8%b5%9b%ef%bc%8c%e5%a5%96%e5%93%81%ef%bc%9a100%e4%b8%87%e7%8e%b0%e9%87%91%ef%bc%8c%e5%a5%94%e9%a9%b0%ef%bc%8c%e6%b6%b2%e6%99%b6%e7%94%b5%e8%a7%86/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 10:53:20 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[财金与投资]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=10260</guid>
		<description />
			<content:encoded><![CDATA[<h2>2009中国股市大奖赛</h2>
<p>十强选手各获得主办方提供的100万实盘资金，专户操作两个月，所获收益90%归选手个人所有，10%捐赠给中国证券投资者保护基金；</p>
<p><strong> 百强选手奖品列表：</strong></p>
<p>名次 奖品 价值（元）<br />
 1 奔驰轿车C200 330,000<br />
 2 夏普液晶电视 9,000<br />
 3 夏普液晶电视 9,000<br />
 4 西铁城电波表 7,500<br />
 5 西铁城光动能手表 5,000<br />
 6-10 G3笔记本 3,500<br />
 11-20 智能手机 2,000</p>
<p>点下面连接参加：<br />
<a title="blocked::http://win.stockstar.com/main/user/toactive.jspa?myRecommender=ericwzy" href="http://win.stockstar.com/main/user/toactive.jspa?myRecommender=ericwzy">http://win.stockstar.com</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/w6KLiATdpPb_Hpw5XR6tN7xA9Ew/0/da"><img src="http://feedads.g.doubleclick.net/~a/w6KLiATdpPb_Hpw5XR6tN7xA9Ew/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/w6KLiATdpPb_Hpw5XR6tN7xA9Ew/1/da"><img src="http://feedads.g.doubleclick.net/~a/w6KLiATdpPb_Hpw5XR6tN7xA9Ew/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=JwR5GQRkk70:2z0HezkcAnA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=JwR5GQRkk70:2z0HezkcAnA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=JwR5GQRkk70:2z0HezkcAnA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=JwR5GQRkk70:2z0HezkcAnA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=JwR5GQRkk70:2z0HezkcAnA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=JwR5GQRkk70:2z0HezkcAnA:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/JwR5GQRkk70" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/09/11/%e6%8a%84%e8%82%a1%e5%a4%a7%e8%b5%9b%ef%bc%8c%e5%a5%96%e5%93%81%ef%bc%9a100%e4%b8%87%e7%8e%b0%e9%87%91%ef%bc%8c%e5%a5%94%e9%a9%b0%ef%bc%8c%e6%b6%b2%e6%99%b6%e7%94%b5%e8%a7%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/09/11/%e6%8a%84%e8%82%a1%e5%a4%a7%e8%b5%9b%ef%bc%8c%e5%a5%96%e5%93%81%ef%bc%9a100%e4%b8%87%e7%8e%b0%e9%87%91%ef%bc%8c%e5%a5%94%e9%a9%b0%ef%bc%8c%e6%b6%b2%e6%99%b6%e7%94%b5%e8%a7%86/</feedburner:origLink></item>
		<item>
		<title>How online payment processing works</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/8yLka5NE0lM/</link>
		<comments>http://www.ericbess.com/ericblog/2009/05/30/how-online-payment-processing-works/#comments</comments>
		<pubDate>Fri, 29 May 2009 16:20:59 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[财金与投资]]></category>
		<category><![CDATA[PayPal]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/05/30/how-online-payment-processing-works/</guid>
		<description><![CDATA[Online payment processing consists of two principal steps: authorization and settlement. The authorization process verifies that the customer’s credit card is active, and that there is sufficient credit to pay for the transaction. During the settlement process, the customer’s card account is charged and money from the customer’s account is transferred to the merchant’s account.
1. [...]]]></description>
			<content:encoded><![CDATA[<p>Online payment processing consists of two principal steps: <strong><em>authorization and settlement</em></strong>. The authorization process verifies that the customer’s credit card is active, and that there is sufficient credit to pay for the transaction. During the settlement process, the customer’s card account is charged and money from the customer’s account is transferred to the merchant’s account.</p>
<h2>1. Payment processing authorization</h2>
<p>During authorization, a bank verifies that holders of a payment instrument, such as a credit card, have sufficient credit or funds to make a purchase.</p>
<ol>
<li>Customer decides to purchase online and inputs credit card information.</li>
<li>Merchant’s website receives customer information and sends it to payment processing service.</li>
<li>Processing service routes information to processor.</li>
<li>Processor routes information to bank that issued customer’s credit card.</li>
<li>Issuing bank sends authorization (or declination) to processor.</li>
<li>Processor routes transaction results to payment processing service.</li>
<li>Processing service sends results to merchant.</li>
<li>Merchant decides to accept or reject purchase. (Here, the merchant should take additional precautions to ensure the 8. credit card is not stolen and that the customer actually owns this card.)</li>
</ol>
<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2009/05/image.png"><img title="image" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="251" alt="image" src="http://www.ericbess.com/ericblog/wp-content/uploads/2009/05/image-thumb.png" width="644" border="0" /></a> </p>
<p> <span id="more-10245"></span><br />
<h2>2. Payment processing settlement</h2>
<p>Once the merchant ships the product or authorizes the download of merchandise, the merchant may request that the payment processing service settle the transaction. During settlement, funds are transferred from the customer’s account to the merchant’s bank account.</p>
<ol>
<li>The merchant informs the payment processing service to settle transactions.</li>
<li>The payment processing service sends transactions to processor.</li>
<li>The processor checks the information, and forwards settled transaction information to the card association and card-issuing bank.</li>
<li>Issuing bank transfers funds to the processor.</li>
<li>Processor routes funds to the acquiring bank.</li>
<li>Acquiring bank credits merchant’s bank account.</li>
<li>Issuing bank includes merchant’s charge on customer’s credit card account.</li>
</ol>
<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2009/05/image1.png"><img title="image" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="271" alt="image" src="http://www.ericbess.com/ericblog/wp-content/uploads/2009/05/image-thumb1.png" width="644" border="0" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/4mABxUGExjviWKkAw9DEdUCoAVY/0/da"><img src="http://feedads.g.doubleclick.net/~a/4mABxUGExjviWKkAw9DEdUCoAVY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/4mABxUGExjviWKkAw9DEdUCoAVY/1/da"><img src="http://feedads.g.doubleclick.net/~a/4mABxUGExjviWKkAw9DEdUCoAVY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8yLka5NE0lM:6vSI2lGgshg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8yLka5NE0lM:6vSI2lGgshg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=8yLka5NE0lM:6vSI2lGgshg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8yLka5NE0lM:6vSI2lGgshg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8yLka5NE0lM:6vSI2lGgshg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8yLka5NE0lM:6vSI2lGgshg:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/8yLka5NE0lM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/05/30/how-online-payment-processing-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/05/30/how-online-payment-processing-works/</feedburner:origLink></item>
		<item>
		<title>PICOL-形象通讯语言(Pictorial Communication Language)</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/js9WwTJdkyg/</link>
		<comments>http://www.ericbess.com/ericblog/2009/04/21/picol/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 03:29:14 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Reading]]></category>
		<category><![CDATA[网站技术]]></category>
		<category><![CDATA[脑海印象]]></category>
		<category><![CDATA[国际化]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/04/21/picol-%e5%bd%a2%e8%b1%a1%e9%80%9a%e8%ae%af%e8%af%ad%e8%a8%80pictorial-communication-language/</guid>
		<description><![CDATA[PICOL:形象通讯语言(Pictorial Communication Language)。PICOL的目标是创建一个“用于电子通信的标准和精简的符号系统”。PICOL可以免费使用，并允许用户自行修改。
人类一直都通过文字来阅读。这种方式有其弊端：

字形表意晦涩，学习困难
种类繁多
同时表达方式单一，只能一行一行的序列陈述

PICOL设计观念为我们展示了一种新颖的沟通语言：就是用通用图标(精简会意符号)。这种语言，通过标准化的会意图标来表达思想，其思想正好解决传统文字的弊端。

方便理解，学习简单：它表现象形，不管你是哪国人，不用学也能明白大概。 
表现方式多样：它也不一定像传统文字那样一行行的排列来陈述，完全可以一在个平面甚至是三维空间中随意组合、运动来表达含义。

有利必有弊，PICOL弊端也很明显。

书写困难： 很难想象所有字都要一个个的画出来，不过计算机时代的到来让这种输入难度急速降低。
表达有限：PICOL现在看来只适合陈述事件与逻辑关系， 要用它来写一篇诗歌或散文，还不如去拍个电影。

下面是一个实例，视频:Internet的历史
这个视频完全运用PICOL来表达。试试禁音“阅读”，在你还没有学过这种语言的情况，看看能理解多少。设想一下，如果还有一段表达同样意思的梵文，你又能理解多少。
如果你曾经对Internet是如何诞生的很好奇，但又没有时间来阅读相关主题的书籍，那一定不要错过Milah Bilgil制作的这段名为”Internet的历史”的简短视频。这段视频对分时(time-sharing)，文件共享(file-sharing)，arpanet以及internet的历史演进作了一个非常形象的介绍。
&#160;
    History of the Internet from PICOL
Reference: http://blog.picol.org/
]]></description>
			<content:encoded><![CDATA[<p>PICOL:形象通讯语言(Pictorial Communication Language)。PICOL的目标是创建一个“用于电子通信的标准和精简的符号系统”。PICOL可以免费使用，并允许用户自行修改。</p>
<p>人类一直都通过文字来阅读。这种方式有其弊端：</p>
<ul>
<li>字形表意晦涩，学习困难</li>
<li>种类繁多</li>
<li>同时表达方式单一，只能一行一行的序列陈述</li>
</ul>
<p>PICOL设计观念为我们展示了一种新颖的沟通语言：就是用通用图标(精简会意符号)。这种语言，通过标准化的会意图标来表达思想，其思想正好解决传统文字的弊端。</p>
<ul>
<li>方便理解，学习简单：它表现象形，不管你是哪国人，不用学也能明白大概。 </li>
<li>表现方式多样：它也不一定像传统文字那样一行行的排列来陈述，完全可以一在个平面甚至是三维空间中随意组合、运动来表达含义。</li>
</ul>
<p>有利必有弊，PICOL弊端也很明显。</p>
<ul>
<li>书写困难： 很难想象所有字都要一个个的画出来，不过计算机时代的到来让这种输入难度急速降低。</li>
<li>表达有限：PICOL现在看来只适合陈述事件与逻辑关系， 要用它来写一篇诗歌或散文，还不如去拍个电影。</li>
</ul>
<p>下面是一个实例，视频:Internet的历史</p>
<p>这个视频完全运用PICOL来表达。试试禁音“阅读”，在你还没有学过这种语言的情况，看看能理解多少。设想一下，如果还有一段表达同样意思的梵文，你又能理解多少。</p>
<p><em>如果你曾经对Internet是如何诞生的很好奇，但又没有时间来阅读相关主题的书籍，那一定不要错过Milah Bilgil制作的这段名为”Internet的历史”的简短视频。这段视频对分时(time-sharing)，文件共享(file-sharing)，arpanet以及internet的历史演进作了一个非常形象的介绍。</em></p>
<p>&#160;</p>
<p align="center"><object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=2696386&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=2696386&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>    <br /><a href="http://vimeo.com/2696386">History of the Internet</a> from <a href="http://vimeo.com/picol">PICOL</a></p>
<p align="left">Reference: <a title="http://blog.picol.org/" href="http://blog.picol.org/">http://blog.picol.org/</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/nITYsyPIBVTcRfykTKEjsg-gOWo/0/da"><img src="http://feedads.g.doubleclick.net/~a/nITYsyPIBVTcRfykTKEjsg-gOWo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nITYsyPIBVTcRfykTKEjsg-gOWo/1/da"><img src="http://feedads.g.doubleclick.net/~a/nITYsyPIBVTcRfykTKEjsg-gOWo/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=js9WwTJdkyg:7rDI83WjmOk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=js9WwTJdkyg:7rDI83WjmOk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=js9WwTJdkyg:7rDI83WjmOk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=js9WwTJdkyg:7rDI83WjmOk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=js9WwTJdkyg:7rDI83WjmOk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=js9WwTJdkyg:7rDI83WjmOk:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/js9WwTJdkyg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/04/21/picol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/04/21/picol/</feedburner:origLink></item>
		<item>
		<title>用Google Trends来做决定</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/E5g9ikprl5w/</link>
		<comments>http://www.ericbess.com/ericblog/2009/04/16/%e7%94%a8google-trends%e6%9d%a5%e5%81%9a%e5%86%b3%e5%ae%9a/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 12:14:19 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[网站技术]]></category>
		<category><![CDATA[CMS]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/04/16/%e7%94%a8google-trends%e6%9d%a5%e5%81%9a%e5%86%b3%e5%ae%9a/</guid>
		<description><![CDATA[一堆东西放在你面前选，拿不定主意。人人都会碰到这样的难题，一个简单的方法就是找Google Trends。
我就是! 想研究一下cms，网上找了很多产品，各有千秋，不知怎么选， 就偷了个懒，让Google Trends 帮我选了。

]]></description>
			<content:encoded><![CDATA[<p align="center">一堆东西放在你面前选，拿不定主意。人人都会碰到这样的难题，一个简单的方法就是找Google Trends。</p>
<p align="center">我就是! 想研究一下cms，网上找了很多产品，各有千秋，不知怎么选， 就偷了个懒，让<a href="http://www.google.com/trends?q=drupal%2C++joomla%2C+mambo%2C++xoops%2C+Plone+&amp;ctab=0&amp;hl=zh-CN&amp;geo=all&amp;geor=all&amp;date=all&amp;sort=0" target="_blank">Google Trends</a> 帮我选了。</p>
<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2009/04/googletrendscms.jpg"><img style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" title="google trends cms" src="http://www.ericbess.com/ericblog/wp-content/uploads/2009/04/googletrendscms-thumb.jpg" border="0" alt="google trends cms" width="614" height="473" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/Bn27qEEKqLPF4hzmJPCLNlLqY54/0/da"><img src="http://feedads.g.doubleclick.net/~a/Bn27qEEKqLPF4hzmJPCLNlLqY54/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Bn27qEEKqLPF4hzmJPCLNlLqY54/1/da"><img src="http://feedads.g.doubleclick.net/~a/Bn27qEEKqLPF4hzmJPCLNlLqY54/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=E5g9ikprl5w:IbNQyH3elyk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=E5g9ikprl5w:IbNQyH3elyk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=E5g9ikprl5w:IbNQyH3elyk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=E5g9ikprl5w:IbNQyH3elyk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=E5g9ikprl5w:IbNQyH3elyk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=E5g9ikprl5w:IbNQyH3elyk:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/E5g9ikprl5w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/04/16/%e7%94%a8google-trends%e6%9d%a5%e5%81%9a%e5%86%b3%e5%ae%9a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/04/16/%e7%94%a8google-trends%e6%9d%a5%e5%81%9a%e5%86%b3%e5%ae%9a/</feedburner:origLink></item>
		<item>
		<title>PCI Data Security Standards (PCI DSS)</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/r18g_W3s28s/</link>
		<comments>http://www.ericbess.com/ericblog/2009/04/15/pci-data-security-standards/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 15:26:44 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[网站技术]]></category>
		<category><![CDATA[财金与投资]]></category>
		<category><![CDATA[PayPal]]></category>
		<category><![CDATA[安全]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/04/15/pci-data-security-standards-pci-dss/</guid>
		<description><![CDATA[写paypal程序有一段时间了。关于电子支付，安全问题非同小可，总是要反复留心。但不管怎么谨慎，按照个人主观标准做的东西总不能保证质量。近日开始系统阅读paypal开发文档，没想到第一课就是PCI DSS（Payment Card Industry Data Security Standards支付卡数据安全工业标准）。有了标准就有质量保证的依据，应该是做电子支付的必修课了。
什么是PCI DSS?

PCI DSS是：支付卡数据安全工业标准

按照支付卡行业安全标准委员会(PCI SSC)需求设计
保护持卡人在支付卡欺诈、遗失、偷盗情况下的数据安全规范


PCI SSC 管理此标准
支付卡公司执行此标准（如：Visa, MasterCard, DiscoverCard and American Express）
PCI DSS适用于持卡人数据存储、处理与传输的全过程 

PCI DSS 目标概略

建设与维护安全网络
保护持卡人数据
维护系统弱点
实行健壮的访问控制
监控与测试网络
维护一个安全策略

遵守PCI DSS
遵守PCI DSS不是一次性目标，它是不断评估与执行的过程。

评估：确定持卡人数据与相关IT设施清单，分析弱点
纠正：修正弱点并保持只对指定数据进行处理
报告：记录所有的行动日志，并通知收单行与有关经营体

PCI DSS 12 Core Requirements
Build and Maintain a Secure Network
Requirement 1 Install and maintain a firewall configuration to protect cardholder data
Requirement 2 Do not use vendor-supplied defaults for system passwords and other security parameters
Protect [...]]]></description>
			<content:encoded><![CDATA[<p>写paypal程序有一段时间了。关于电子支付，安全问题非同小可，总是要反复留心。但不管怎么谨慎，按照个人主观标准做的东西总不能保证质量。近日开始系统阅读paypal开发文档，没想到第一课就是PCI DSS（Payment Card Industry Data Security Standards支付卡数据安全工业标准）。有了标准就有质量保证的依据，应该是做电子支付的必修课了。</p>
<h2>什么是PCI DSS?</h2>
<ul>
<li>PCI DSS是：支付卡数据安全工业标准
<ul>
<li>按照支付卡行业安全标准委员会(PCI SSC)需求设计</li>
<li>保护持卡人在支付卡欺诈、遗失、偷盗情况下的数据安全规范</li>
</ul>
</li>
<li>PCI SSC 管理此标准</li>
<li>支付卡公司执行此标准（如：Visa, MasterCard, DiscoverCard and American Express）</li>
<li>PCI DSS适用于持卡人数据存储、处理与传输的全过程 </li>
</ul>
<h2>PCI DSS 目标概略</h2>
<ul>
<li>建设与维护安全网络</li>
<li>保护持卡人数据</li>
<li>维护系统弱点</li>
<li>实行健壮的访问控制</li>
<li>监控与测试网络</li>
<li>维护一个安全策略</li>
</ul>
<h2>遵守PCI DSS</h2>
<p>遵守PCI DSS不是一次性目标，它是不断评估与执行的过程。</p>
<ul>
<li>评估：确定持卡人数据与相关IT设施清单，分析弱点</li>
<li>纠正：修正弱点并保持只对指定数据进行处理</li>
<li>报告：记录所有的行动日志，并通知收单行与有关经营体</li>
</ul>
<h2>PCI DSS 12 Core Requirements</h2>
<p>Build and Maintain a Secure Network<br />
Requirement 1 Install and maintain a firewall configuration to protect cardholder data<br />
Requirement 2 Do not use vendor-supplied defaults for system passwords and other security parameters</p>
<p>Protect Cardholder Data<br />
Requirement 3 Protect stored cardholder data<br />
Requirement 4 Encrypt transmission of cardholder data across open, public networks</p>
<p>Maintain a Vulnerability Management Program<br />
Requirement 5 Use and regularly update anti-virus software<br />
Requirement 6 Develop and maintain secure systems and applications</p>
<p>Implement Strong Access Control Measures<br />
Requirement 7 Restrict access to cardholder data by business need-to-know<br />
Requirement 8 Assign a unique ID to each person with computer access<br />
Requirement 9 Restrict physical access to cardholder data</p>
<p>Regularly Monitor and Test Networks<br />
Requirement 10 Track and monitor all access to network resources and cardholder data<br />
Requirement 11 Regularly test security systems and processes</p>
<p>Maintain an Information Security Policy<br />
Requirement 12 Maintain a policy that addresses information security</p>

<p><a href="http://feedads.g.doubleclick.net/~a/4LEb2CNogNcvcTorhKQNSJAbLU4/0/da"><img src="http://feedads.g.doubleclick.net/~a/4LEb2CNogNcvcTorhKQNSJAbLU4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/4LEb2CNogNcvcTorhKQNSJAbLU4/1/da"><img src="http://feedads.g.doubleclick.net/~a/4LEb2CNogNcvcTorhKQNSJAbLU4/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=r18g_W3s28s:vKuZ0HotdF4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=r18g_W3s28s:vKuZ0HotdF4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=r18g_W3s28s:vKuZ0HotdF4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=r18g_W3s28s:vKuZ0HotdF4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=r18g_W3s28s:vKuZ0HotdF4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=r18g_W3s28s:vKuZ0HotdF4:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/r18g_W3s28s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/04/15/pci-data-security-standards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/04/15/pci-data-security-standards/</feedburner:origLink></item>
		<item>
		<title>my reading: A short history of Chinese philosophy</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/zsuMsNzpOaU/</link>
		<comments>http://www.ericbess.com/ericblog/2009/03/28/chinese-philosophy/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 13:47:07 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Reading]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/03/28/my-reading-a-short-history-of-china-philosophy/</guid>
		<description><![CDATA[A short history of China philosophy  by:Fung Yu-Lan
The sentences deserve to be noted.
Chapter 1: The Spirit of Chinese philosophy
The place which philosophy has occupied in chinese civilization has been comparable to that of religion on other civilizations.
Place of philosophy in Chinese Civilization
A present it is known to many Westerners that the Chinese people have been [...]]]></description>
			<content:encoded><![CDATA[<p><em>A short history of China philosophy  by:Fung Yu-Lan</em></p>
<p>The sentences deserve to be noted.</p>
<h1>Chapter 1: The Spirit of Chinese philosophy</h1>
<p>The place which philosophy has occupied in chinese civilization has been comparable to that of religion on other civilizations.</p>
<h2>Place of philosophy in Chinese Civilization</h2>
<p>A present it is known to many Westerners that the Chinese people have been less concerned with religion than other people are. &#8230;&#8230;. When one says it is ethics, not religion, that has provided the spiritual basis of Chinese civiliztion, does it imply that the Chinese are not conscious of those values which are highter than moral ones? &#8230;&#8230;To answer ther above questions, I would say that the craving for something beyond the present actual world is one of the innate desires of mankind, and the Chinese people are no exception to the rule. They have not had much concern with religion because thay have had so much concern with pphilosophy. They are not religious because they are philosophical. in philosophy they satisfy their craving for what is beyond the present actual world. In philosophy also they have the super-moral values expressed and appreciated, and in living according to philosophy these super-moral values are experienced.</p>
<h2>Problem and Spirit of Chinese philosophy</h2>
<p>“不离日用常行内，直到先天未画前”. &#8220;It is not divorced from the daily ordinary activities, yet it gose straight to what antedated Heaven.” This is what Chinese philosophy has striven for.</p>
<p>The man who accomplishes this synthesis, not only in theory but also in deed, is the sage.</p>
<h2>The Way in which Chinese Philosophers Expressed Themseleves</h2>
<p>According to the chinese trandition, the study of philosophy is not a profession. Everyone should study philosophy just like in the West every on should go to church. The purpose of the study of philosophy is to enable a man, as man, to be a man, no some ……</p>
<p>“言者所以在意，得意而忘言,吾安得夫忘言之人而与之言哉！”<br />
Words a for holding on ideal, but when one has got the ideal, one need no longer think about the words. If only I could find someone who had stopped thinking about words and could have him with me to talk to! &#8211;&#8221;when their eyes met, the Tao was there&#8221; or &#8220;the Tao cannot be told, but only suggested.&#8221;</p>
<h1>Chapter 2: The Background of Chinese philososphy</h1>
<h2>Chinese Art and Poetry</h2>
<p>The Confucianists took art as an instrument for moral education. The Taoists admiration of the free movement of the spirit and their idealization of nature gave profound inspiration to the great artists of China. &#8230;&#8230;Likewise in Chinese poetry we find suck poems as that by T&#8217;ao Ch&#8217;ien(A.D.372-427):“结庐在人境，而无车马喧。问君何能尔，心远地自偏。采菊东篱下，悠然见南山。山气日夕佳，飞鸟相与还。此中有真意，欲辨已忘言。 ”</p>
<p style="padding-left: 30px;">I built my hut in a zone of human habitation,<br />
Yat near me there sounds no noise of horse or coach,<br />
Would you know how that is possible?<br />
A heart that is distant creates a wilderness round it.<br />
I pluck chrysanthemums under the eastern hedge,<br />
Then gaze long at the distant summer hills.<br />
The mountain air is fresh at the dusk of day;<br />
The flying birds two by two return.<br />
In these thing there lies a deep meaning;<br />
Yet when we would expressit, words suddenly fail us.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/cAPzOKhcE7s47Ju59qzd0FJdRMM/0/da"><img src="http://feedads.g.doubleclick.net/~a/cAPzOKhcE7s47Ju59qzd0FJdRMM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/cAPzOKhcE7s47Ju59qzd0FJdRMM/1/da"><img src="http://feedads.g.doubleclick.net/~a/cAPzOKhcE7s47Ju59qzd0FJdRMM/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=zsuMsNzpOaU:WFUUDzccSmg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=zsuMsNzpOaU:WFUUDzccSmg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=zsuMsNzpOaU:WFUUDzccSmg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=zsuMsNzpOaU:WFUUDzccSmg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=zsuMsNzpOaU:WFUUDzccSmg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=zsuMsNzpOaU:WFUUDzccSmg:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/zsuMsNzpOaU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/03/28/chinese-philosophy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/03/28/chinese-philosophy/</feedburner:origLink></item>
		<item>
		<title>美元贬值与黄金坐庄</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/dnmWE-HciqA/</link>
		<comments>http://www.ericbess.com/ericblog/2009/03/20/glod_usd/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 13:22:48 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[投资感想]]></category>
		<category><![CDATA[盘中记录]]></category>
		<category><![CDATA[脑海印象]]></category>
		<category><![CDATA[黄金]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/03/20/%e7%be%8e%e5%85%83%e8%b4%ac%e5%80%bc%e4%b8%8e%e9%bb%84%e9%87%91%e5%9d%90%e5%ba%84/</guid>
		<description><![CDATA[
震荡与贬值
前晚睡觉前，已过零点，习惯性的看看金价，急跌至五周低位883$，已低于自己的目标买入价。但是，如此急跌是否有对金价不利的系统风险出现，保守起见没有行动。可就在我睡下的一个小时里金价急升到950$一带，震幅巨大。原来隔夜美联储采取量化宽松货币政策，印钞300,000,000,000$以收购美国长期国债提振金融市场，美指急挫至近两个月低位。美元贬值，黄金当然要涨。
让我不明白的一点是，涨可以理解，那之前的大幅下跌又是怎么回事，而且就在利好消息公布之前，怎么让人感觉就像咱们家A股市场的恶庄行为。可要知道黄金做为全球通行的准货币，理论上不应该有坐庄这类非系统性风险存在，不过仅为理论上如此。同样，事实上某些大庄还是能轻易的制造出一些系统风险，从而牟取利益。比如美国政府。量化宽松货币政策说白了就是大开印钞机贬值美元来得利自己，而持有大量美国国债的债权国就将为此蒙受巨大损失。
细节中的本质
注意一个细节，就在几天前，美国总统奥巴马在与访美的巴西总统卢拉会谈后的记者会上表示，包括中国在内的全世界投资者都应对其在美国投资的安全性有“绝对信心”。（美国总统奥巴马急给中国投资定心丸）我们可怜的总理的好觉还没睡上几晚（温家宝：中国是美最大债权国 担心中国资产安全），老实人就被忽悠了。可以肯定，当时说这话的美国总统已知道今后几天将发生什么事了。
想想这一阴阳行径与右边这张“黄金坐庄图”有什么区别！事实告诉我们，越大的庄家越是无信可言，在利益面前，信誉一文不值。对于庄家而言，信誉只是让善良的人们放弃自己权力的一种手段！
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2009/03/gold.jpg"><img style="border-right: 0px; border-top: 0px; display: inline; margin-left: 0px; border-left: 0px; margin-right: 0px; border-bottom: 0px" title="Gold" src="http://www.ericbess.com/ericblog/wp-content/uploads/2009/03/gold-thumb.jpg" border="0" alt="Gold" width="503" height="524" align="right" /></a></p>
<h2>震荡与贬值</h2>
<p>前晚睡觉前，已过零点，习惯性的看看金价，急跌至五周低位883$，已低于自己的目标买入价。但是，如此急跌是否有对金价不利的系统风险出现，保守起见没有行动。可就在我睡下的一个小时里金价急升到950$一带，震幅巨大。原来隔夜美联储采取量化宽松货币政策，印钞300,000,000,000$以收购美国长期国债提振金融市场，美指急挫至近两个月低位。美元贬值，黄金当然要涨。</p>
<p>让我不明白的一点是，涨可以理解，那之前的大幅下跌又是怎么回事，而且就在利好消息公布之前，怎么让人感觉就像咱们家A股市场的恶庄行为。可要知道黄金做为全球通行的准货币，理论上不应该有坐庄这类非系统性风险存在，不过仅为理论上如此。同样，事实上某些大庄还是能轻易的制造出一些系统风险，从而牟取利益。比如美国政府。量化宽松货币政策说白了就是大开印钞机贬值美元来得利自己，而持有大量美国国债的债权国就将为此蒙受巨大损失。</p>
<h2>细节中的本质</h2>
<p>注意一个细节，就在几天前，美国总统奥巴马在与访美的巴西总统卢拉会谈后的记者会上表示，包括<strong>中国</strong>在内的全世界投资者都应对其在美国投资的安全性有“<strong>绝对信心</strong>”。（<a href="http://qizhi.hexun.com/2009-03-16/115655365.html" target="_blank">美国总统奥巴马急给中国投资定心丸</a>）我们可怜的总理的好觉还没睡上几晚（<a href="http://finance.sina.com.cn/china/hgjj/20090313/10405972144.shtml" target="_blank">温家宝：中国是美最大债权国 担心中国资产安全</a>），老实人就被忽悠了。可以肯定，当时说这话的美国总统已知道今后几天将发生什么事了。</p>
<p>想想这一阴阳行径与右边这张“黄金坐庄图”有什么区别！事实告诉我们，越大的庄家越是无信可言，在利益面前，信誉一文不值。对于庄家而言，信誉只是让善良的人们放弃自己权力的一种手段！</p>

<p><a href="http://feedads.g.doubleclick.net/~a/BRw5cutuVSea69khjaN4Iig9foA/0/da"><img src="http://feedads.g.doubleclick.net/~a/BRw5cutuVSea69khjaN4Iig9foA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/BRw5cutuVSea69khjaN4Iig9foA/1/da"><img src="http://feedads.g.doubleclick.net/~a/BRw5cutuVSea69khjaN4Iig9foA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=dnmWE-HciqA:A10BKEboxso:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=dnmWE-HciqA:A10BKEboxso:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=dnmWE-HciqA:A10BKEboxso:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=dnmWE-HciqA:A10BKEboxso:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=dnmWE-HciqA:A10BKEboxso:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=dnmWE-HciqA:A10BKEboxso:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/dnmWE-HciqA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/03/20/glod_usd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/03/20/glod_usd/</feedburner:origLink></item>
		<item>
		<title>IBM 6.5B$收购SUN,靠谱吗！</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/gDEpZhZVb9U/</link>
		<comments>http://www.ericbess.com/ericblog/2009/03/19/ibm-sun/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 14:02:06 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[脑海印象]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[品牌作用]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/03/19/ibm-65b%e6%94%b6%e8%b4%adsun%e9%9d%a0%e8%b0%b1%e5%90%97%ef%bc%81/</guid>
		<description><![CDATA[江湖老大IBM要出手收购SUN,价钱不错，机会很好，华尔街消息一出，市场立即骚动，Sun股价即涨125%， 近来少见。看看下图，那个“G”。IBM Corporation In Talks To Buy Sun Microsystems, Inc.

Good deal, Good ideal!
如果这事能成,当然是好交易，看看6.5B$买了什么，其实我并不能说全，试着说说大多数人都知道的：Java：最流行跨界开发平台，.NET的宿敌; Solaris: 30% 高端主机市场占有率; Mysql: LAMP平台重要一环，商业数据库强劲对手;  还有open office; networking storage &#38; computing &#38; cloud。这些和IBM现有的产品体系与发展战略结合足以影响整个IT业发展的轨迹。有这么夸张吗？！
想像一下！

那些Java.NET程序员听到这个消息时会怎么想？
Java 与 .NET之争的天平是否已倾斜？
两家全面支持开源的巨头结合，是否宣告软件业赚钱的模式正在改变?
主机市场会否一家独大？
wintel架构是否迎来真正挑战？
竞争格局是否已被打破?Sun Deal May Trigger More Takeovers as Technology Icons Fade

就近来说，如果交易成功，给IBM带来的现实要好处也不少。
江湖地位
老大位置得以保全，事实上因为HP与EDS的合并已把IBM从老大的位置上请了下来，市场其实也有评论说IBM此次行动就是针对HPQ的挑战。IBM Takes Aim at Hewlett-Packard
Cross-Sell
10年来，IBM一直都在逐步撤离硬件市场以便将IBM的注意力转向利润更加丰厚的软件和服务领域。收购Sun将为IBM增加130亿美元的销售额，并获得服务器市场的不菲份额,这类产品通常都是卖给大型公司或政府用于建造数据中心的,反过来这些也正是IBM软件和服务领域重要客户。每卖出一台Sun的服务器，IBM都将有机会出售自己的服务、设施及更新，同时也可以为用户提供相关的软件以便使其更好的运行互联网应用程序。
垄断市场痛击对手
合并后，新公司的服务器市场收入份额将高达42%，而在Unix服务器市场的份额更是高达65%。新公司在存储器市场的份额也接近50%，在高端企业服务器市场的份额超过60%。有了SUN，IBM可以组装更强大，更灵活的软件服务平台。有了Sun，IBM就可以利用当前的经济下滑及其相对健康的状况，以低廉的产品价格痛击对手。收购了Sun及其软件后，IBM将会在与X86架构的竞争中更进一步。后者是英特尔处理器的主要架构，并得到了惠普、戴尔、微软等公司的力挺，被广泛应用于服务器中。
削减成本
两家公司合并后，员工总数将超过43万人，硅谷的科技人员将因此而面临阵痛。IBM必须要削减10亿美元的成本才能使得Sun的产品盈利水平与IBM自己的硬件业务持平。从财务上讲，IBM可以借此为股东创造价值。
靠谱吗！？
说实话，当我第一眼看到这个消息时，大感意外，总觉不靠谱。
首先，这事好像太便宜了，6.5B买SUN也太便宜了吧，如果这个价合理，13.9B买EDS的那家不是要吐血了。
其次，一般雷声大雨点就小，IT业收购经验告示我，事前放出消息的收购案一般阻力就大，微软，IBM都吃过亏，不知道这次是否是个例外。
还有就是蛋糕都给你分走了，家长就要出来说话了。如果收购成功，新公司在很多领域份额都超过50%，这将引发监管问题，在欧洲市场尤其如此。这将激发大规模的审查，而审查的前提假设对IBM非常不利。
无论如何，这个收购案给我们打开了神奇想象空间。不管成功与否，肯定是个Good ideal, 不过要让它成为Good deal，就要让我们拭目以待了！
]]></description>
			<content:encoded><![CDATA[<p>江湖老大IBM要出手收购SUN,价钱不错，机会很好，华尔街消息一出，市场立即骚动，Sun股价即涨125%， 近来少见。看看下图，那个“G”。<a href="http://www.reuters.com/finance/stocks/keyDevelopments?symbol=JAVA.O&amp;timestamp=20090318091300&amp;rpc=66" target="_blank">IBM Corporation In Talks To Buy Sun Microsystems, Inc.</a></p>
<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2009/03/sunibm.jpg"><img style="display: inline; margin-left: 0px; margin-right: 0px; border: 0px;" title="SUN IBM" src="http://www.ericbess.com/ericblog/wp-content/uploads/2009/03/sunibm-thumb.jpg" border="0" alt="SUN IBM" width="564" height="349" align="right" /></a></p>
<h2>Good deal, Good ideal!</h2>
<p>如果这事能成,当然是好交易，看看6.5B$买了什么，其实我并不能说全，试着说说大多数人都知道的：Java：最流行跨界开发平台，.NET的宿敌; Solaris: 30% 高端主机市场占有率; Mysql: LAMP平台重要一环，商业数据库强劲对手;  还有open office; networking storage &amp; computing &amp; cloud。这些和IBM现有的产品体系与发展战略结合足以影响整个IT业发展的轨迹。有这么夸张吗？！</p>
<p>想像一下！</p>
<ul>
<li>那些Java.NET程序员听到这个消息时会怎么想？</li>
<li>Java 与 .NET之争的天平是否已倾斜？</li>
<li>两家全面支持开源的巨头结合，是否宣告软件业赚钱的模式正在改变?</li>
<li>主机市场会否一家独大？</li>
<li>wintel架构是否迎来真正挑战？</li>
<li>竞争格局是否已被打破?<a href="http://www.bloomberg.com/apps/news?pid=20601087&amp;sid=asHghrDMLdiM&amp;refer=home" target="_blank">Sun Deal May Trigger More Takeovers as Technology Icons Fade</a></li>
</ul>
<p>就近来说，如果交易成功，给IBM带来的现实要好处也不少。</p>
<h4>江湖地位</h4>
<p>老大位置得以保全，事实上因为HP与EDS的合并已把IBM从老大的位置上请了下来，市场其实也有评论说IBM此次行动就是针对HPQ的挑战。<a href="http://www.istockanalyst.com/article/viewarticle/articleid/3129112" target="_blank">IBM Takes Aim at Hewlett-Packard</a></p>
<h4>Cross-Sell</h4>
<p>10年来，IBM一直都在逐步撤离硬件市场以便将IBM的注意力转向利润更加丰厚的软件和服务领域。收购Sun将为IBM增加130亿美元的销售额，并获得服务器市场的不菲份额,这类产品通常都是卖给大型公司或政府用于建造数据中心的,反过来这些也正是IBM软件和服务领域重要客户。每卖出一台Sun的服务器，IBM都将有机会出售自己的服务、设施及更新，同时也可以为用户提供相关的软件以便使其更好的运行互联网应用程序。</p>
<h4><strong>垄断市场<strong>痛击对手</strong></strong></h4>
<p>合并后，新公司的服务器市场收入份额将高达42%，而在Unix服务器市场的份额更是高达65%。新公司在存储器市场的份额也接近50%，在高端企业服务器市场的份额超过60%。有了SUN，IBM可以组装更强大，更灵活的软件服务平台。有了Sun，IBM就可以利用当前的经济下滑及其相对健康的状况，以低廉的产品价格痛击对手。收购了Sun及其软件后，IBM将会在与X86架构的竞争中更进一步。后者是英特尔处理器的主要架构，并得到了惠普、戴尔、微软等公司的力挺，被广泛应用于服务器中。</p>
<h4><strong>削减成本</strong></h4>
<p>两家公司合并后，员工总数将超过43万人，硅谷的科技人员将因此而面临阵痛。IBM必须要削减10亿美元的成本才能使得Sun的产品盈利水平与IBM自己的硬件业务持平。从财务上讲，IBM可以借此为股东创造价值。</p>
<h2>靠谱吗！？</h2>
<p>说实话，当我第一眼看到这个消息时，大感意外，总觉不靠谱。</p>
<p>首先，这事好像太便宜了，6.5B买SUN也太便宜了吧，如果这个价合理，13.9B买EDS的那家不是要吐血了。</p>
<p>其次，一般雷声大雨点就小，IT业收购经验告示我，事前放出消息的收购案一般阻力就大，微软，IBM都吃过亏，不知道这次是否是个例外。</p>
<p>还有就是<strong>蛋糕都给你分走了，家长就要出来说话了。</strong>如果收购成功，新公司在很多领域份额都超过50%，这将引发监管问题，在欧洲市场尤其如此。这将激发大规模的审查，而审查的前提假设对IBM非常不利。</p>
<p>无论如何，这个收购案给我们打开了神奇想象空间。不管成功与否，肯定是个Good ideal, 不过要让它成为Good deal，就要让我们拭目以待了！</p>

<p><a href="http://feedads.g.doubleclick.net/~a/-MlZgtbSaOJ9xfy-DE-6w6DTUNw/0/da"><img src="http://feedads.g.doubleclick.net/~a/-MlZgtbSaOJ9xfy-DE-6w6DTUNw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/-MlZgtbSaOJ9xfy-DE-6w6DTUNw/1/da"><img src="http://feedads.g.doubleclick.net/~a/-MlZgtbSaOJ9xfy-DE-6w6DTUNw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gDEpZhZVb9U:KjVgoevii2Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gDEpZhZVb9U:KjVgoevii2Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=gDEpZhZVb9U:KjVgoevii2Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gDEpZhZVb9U:KjVgoevii2Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gDEpZhZVb9U:KjVgoevii2Q:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gDEpZhZVb9U:KjVgoevii2Q:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/gDEpZhZVb9U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/03/19/ibm-sun/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/03/19/ibm-sun/</feedburner:origLink></item>
		<item>
		<title>丰田和福特独木舟比赛</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/x2eCP4HDnII/</link>
		<comments>http://www.ericbess.com/ericblog/2009/03/10/%e4%b8%b0%e7%94%b0%e5%92%8c%e7%a6%8f%e7%89%b9%e7%8b%ac%e6%9c%a8%e8%88%9f%e6%af%94%e8%b5%9b/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 08:49:55 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Reading]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/03/10/%e4%b8%b0%e7%94%b0%e5%92%8c%e7%a6%8f%e7%89%b9%e7%8b%ac%e6%9c%a8%e8%88%9f%e6%af%94%e8%b5%9b/</guid>
		<description><![CDATA[午餐时，听sales说丰田和福特独木舟比赛的老笑话，其实大家都知道现实中正在发生着相似的事例。只是最近这类感触特别多，所以这个笑话又成了我们今天共同的话题。
日本丰田汽车公司和美国福特公司决定在密西西比河上进行一场独木舟比赛。
两个队进行了长时间的练习，比赛之前难以达到其最佳表现。比赛那天，日本队以一英里的优势取胜。灰心丧气的美国队决定调查大败原因。他们组织了一个由高级管理人员组成的管理团队，分析原因并提出适当的作战计划。分析结果出来了：日本队有八人划船，一人掌舵；而美国队有七人掌舵，两人划船。美国管理团队认为有必要进行更深入的研究，于是，他们重金雇用了一家咨询公司进行二次分析。自然，咨询公司也认为掌舵人太多、而划船人数不够才导致了这样的结局。   在不知道如何利用这一信息、又怕再次输给日本队的情况下，美国队彻底重组了他们的比赛团队管理机构：这次出场的是 4 名舵手监督、2 名分区域主舵、1 名掌舵经理助理。他们还实行了新的绩效体系，以使两名划船队员有巨大的动力去努力工作。这一绩效体系被称为“划船队质量第一体系”。划船队员可以得到接见、晚餐和自由笔。他们还就购买新划桨、独木舟和其它设备、提供额外假期供其练习以及提供奖金进行了讨论。养老金被削减，用于“赞助比赛”，省下来的一部分钱用于鼓舞士气和团队合作海报方面的支出。    第二年，日本队赢了 2 英里。美国队管理层很没面子，于是他们辞退了一名划船队员，停止了新独木舟的开发，卖掉了所有的划桨，取消了所有的新设备投资。省下来的钱以奖金的形式发给了高管们。又过了一年，唯一一名上场划手竟然没能完成比赛，因业绩不佳而被辞退。美国队卖掉了所有的设备，把下一年的比赛团队外包给了印度。    
福特用了 30 年的时间，把它所有的工厂迁出了美国，声称他们赚的钱付不起美国人的工资；而丰田则用了 30 年的时间，在美国境内建了十几个工厂。之前一个季度的结果显示：丰田获得了 40 亿的利润，而福特则获得 90 亿的亏损。福特人仍然在搔着头皮、聚敛着奖金…
]]></description>
			<content:encoded><![CDATA[<p>午餐时，听sales说丰田和福特独木舟比赛的老笑话，其实大家都知道现实中正在发生着相似的事例。只是最近这类感触特别多，所以这个笑话又成了我们今天共同的话题。</p>
<p>日本丰田汽车公司和美国福特公司决定在密西西比河上进行一场独木舟比赛。</p>
<p>两个队进行了长时间的练习，比赛之前难以达到其最佳表现。比赛那天，日本队以一英里的优势取胜。灰心丧气的美国队决定调查大败原因。他们组织了一个由高级管理人员组成的管理团队，分析原因并提出适当的作战计划。分析结果出来了：日本队有八人划船，一人掌舵；而美国队有七人掌舵，两人划船。美国管理团队认为有必要进行更深入的研究，于是，他们重金雇用了一家咨询公司进行二次分析。自然，咨询公司也认为掌舵人太多、而划船人数不够才导致了这样的结局。   <br />在不知道如何利用这一信息、又怕再次输给日本队的情况下，美国队彻底重组了他们的比赛团队管理机构：这次出场的是 4 名舵手监督、2 名分区域主舵、1 名掌舵经理助理。他们还实行了新的绩效体系，以使两名划船队员有巨大的动力去努力工作。这一绩效体系被称为“划船队质量第一体系”。划船队员可以得到接见、晚餐和自由笔。他们还就购买新划桨、独木舟和其它设备、提供额外假期供其练习以及提供奖金进行了讨论。养老金被削减，用于“赞助比赛”，省下来的一部分钱用于鼓舞士气和团队合作海报方面的支出。    <br />第二年，日本队赢了 2 英里。美国队管理层很没面子，于是他们辞退了一名划船队员，停止了新独木舟的开发，卖掉了所有的划桨，取消了所有的新设备投资。省下来的钱以奖金的形式发给了高管们。又过了一年，唯一一名上场划手竟然没能完成比赛，因业绩不佳而被辞退。美国队卖掉了所有的设备，把下一年的比赛团队外包给了印度。    </p>
<p>福特用了 30 年的时间，把它所有的工厂迁出了美国，声称他们赚的钱付不起美国人的工资；而丰田则用了 30 年的时间，在美国境内建了十几个工厂。之前一个季度的结果显示：丰田获得了 40 亿的利润，而福特则获得 90 亿的亏损。福特人仍然在搔着头皮、聚敛着奖金…</p>

<p><a href="http://feedads.g.doubleclick.net/~a/4I9gLp_KzdN1Mm2iqqHavE62uoc/0/da"><img src="http://feedads.g.doubleclick.net/~a/4I9gLp_KzdN1Mm2iqqHavE62uoc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/4I9gLp_KzdN1Mm2iqqHavE62uoc/1/da"><img src="http://feedads.g.doubleclick.net/~a/4I9gLp_KzdN1Mm2iqqHavE62uoc/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=x2eCP4HDnII:ywE8BZoaJtY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=x2eCP4HDnII:ywE8BZoaJtY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=x2eCP4HDnII:ywE8BZoaJtY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=x2eCP4HDnII:ywE8BZoaJtY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=x2eCP4HDnII:ywE8BZoaJtY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=x2eCP4HDnII:ywE8BZoaJtY:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/x2eCP4HDnII" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/03/10/%e4%b8%b0%e7%94%b0%e5%92%8c%e7%a6%8f%e7%89%b9%e7%8b%ac%e6%9c%a8%e8%88%9f%e6%af%94%e8%b5%9b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/03/10/%e4%b8%b0%e7%94%b0%e5%92%8c%e7%a6%8f%e7%89%b9%e7%8b%ac%e6%9c%a8%e8%88%9f%e6%af%94%e8%b5%9b/</feedburner:origLink></item>
		<item>
		<title>iTunes、iPhone等使用技巧，来看看绝对有帮助!</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/-qGxblY1EN4/</link>
		<comments>http://www.ericbess.com/ericblog/2009/01/09/iphone-skill/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 07:37:30 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/01/09/itunes%e3%80%81iphone%e7%ad%89%e4%bd%bf%e7%94%a8%e6%8a%80%e5%b7%a7%ef%bc%8c%e6%9d%a5%e7%9c%8b%e7%9c%8b%e7%bb%9d%e5%af%b9%e6%9c%89%e5%b8%ae%e5%8a%a9/</guid>
		<description><![CDATA[
iTunes使用技巧：
1、编辑－偏好设置－设备里，禁用iPhone和iPod自动同步最好打上勾，可防止链接上iPhone后就自动同步；
2、iTunes里的iPhone界面上，采用手动管理音乐和视频可以方便管理iPod，音乐视频等可以直接从Windows资源管理器上直接拖进iPhone的影片里而不必添加到iTunes里；
3、iPhone里的视频右击－显示简介－信息，在归类里填上EXPLICIT，可以在iPod里隐藏该视频，iPhone上在设置－通用－限制里打开此功能；
4、iPhone里的视频iPhone里的视频右击－显示简介－选项，媒体种类里选择音乐视频，然后iPod里用所有音乐的方式找到该视频，可以实现竖屏播放，并可以连续播放视频文件；
5、iPhone里的音乐文件右击－显示简介－选项，媒体种类里选择有声读物，可以让该音乐文件在iPod里的有声读物里出现，并可以记忆播放位置；
6、把 .app软件文件夹拖到iTunes8.02的应用程序窗口，可以直接生成IPA程序，使用该方法生成的IPA程序在iTunes里无预览图标，且部分程序使用该方法生成的IPA在iPhone上无法打开；
7、iTunes上的音乐文件点右键创建ACC版本，再在生成的文件上点右键，在资源管理器上显示，把这个文件的后缀名改为m4r，把这个文件用WinSCP传到/private/var/stash/Ringtones目录里，再把这个文件拖到iTunes上iPhone的铃声里，这样不管你怎么同步，铃声都不会消失，也没有45秒的时间限制；
8、新刷是固件在正确破解了MobileInstallation文件后，但同步进去的破解软件依然无法打开的，请删掉后，同步一个免费的软件；

iPhone使用技巧：
1、来电话时，按一下电源键为静音，再按一下为拒接；
2、锁屏状态，双击Home键可以调出iPod小面版，桌面状态则打开iPod（可在设置－通用－主屏幕按钮里设置）；
3、设置－邮件、通讯录、日历里可以直接导入SIM上联系人；
4、用IPA格式安装的软件的设置有时候不在软件界面，而是将设置项新增加到iPhone的“设置”里；
5、iPod里的视频是可以直接删除的，在文件名上从左往右划一下即可，还有很多地方可以用此方法来删除文件；
6、英文输入时，双击大小写切换键可以锁定大写（设置－通用－键盘里可以设置）；
7、时钟里的计时器里的iPod睡眠模式可以让iPod在指定的时间里关闭；
8、发短信时，按了发送后就可以关掉做别的了，不必等待发送完毕，短信会后台发送直至发送完毕；
9、iTunes里的多媒体文件点击下载后就可以关掉做别的了，它会自动后台下载；
10、打电话时，你可以按掉Home键后，玩点别的不必担心会断线；
11、在查看长列表时，点一下顶上的一条可以快速回到列表顶端，比如Safari、联系人等等；
12、无论什么时候，按住电源键不放，再按一下Home键可以把当前屏幕保存到照片里，在iPhone上的存档目录为/private/var/mobile/Media/DCIM/999APPLE/ ；
注：仅适用于2.0以上固件
13、原装的耳麦除了按一下接听/挂断电话外，在点亮屏幕的状态下可以开启/关闭iPod，按两下可以下一首，按三下可以上一首；
其他技巧：
1、重刷固件前，你要备份的东西全部都在这里/private/var/mobile目录下的相关文件中，其中
Library下：AddressBook为电话本、Calendar为日历、CallHistory为通话记录、Mail为电邮、 Notes为备忘录、Safari为收藏夹、SMS为短信；
Media下： DCIM为照相机拍的照片和截屏、Photos为电脑里同步进去的图片、iTunes_Control为音乐、电影、铃声文件；
2、新刷的固件如果遇到一些奇怪的问题，比如照片拍起来空白或者是照片无法保存、备忘录不能保存等，多半是权限的问题，到上述的相应目录改一下权限，直接改为777试一下；
3、IPA安装的软件集中在/private/var/mobile/Applications，但文件名是随机的；
4、/private/var/mobile/Media/iTunes_Control/Music下是iPod里的音乐视频文件，虽然文件名是随机的，但Mp3的ID信息并没有问题，可以复制到任何电脑上正常播放，也可以用批量ID信息编辑器重新整理，几百首歌五分钟就可以修改完；
5、当iPhone通过USB连接到iTunes时，iTunes提示iPhone需要恢复，可尝试请删除/private/var/mobile/Media/iTunes_Control/目录，重启iPhone后再重新连接到iTunes即可.
]]></description>
			<content:encoded><![CDATA[</p>
<h4>iTunes使用技巧：</h4>
<p>1、编辑－偏好设置－设备里，禁用iPhone和iPod自动同步最好打上勾，可防止链接上iPhone后就自动同步；</p>
<p>2、iTunes里的iPhone界面上，采用手动管理音乐和视频可以方便管理iPod，音乐视频等可以直接从Windows资源管理器上直接拖进iPhone的影片里而不必添加到iTunes里；</p>
<p>3、iPhone里的视频右击－显示简介－信息，在归类里填上EXPLICIT，可以在iPod里隐藏该视频，iPhone上在设置－通用－限制里打开此功能；</p>
<p>4、iPhone里的视频iPhone里的视频右击－显示简介－选项，媒体种类里选择音乐视频，然后iPod里用所有音乐的方式找到该视频，可以实现竖屏播放，并可以连续播放视频文件；</p>
<p>5、iPhone里的音乐文件右击－显示简介－选项，媒体种类里选择有声读物，可以让该音乐文件在iPod里的有声读物里出现，并可以记忆播放位置；</p>
<p>6、把 .app软件文件夹拖到iTunes8.02的应用程序窗口，可以直接生成IPA程序，使用该方法生成的IPA程序在iTunes里无预览图标，且部分程序使用该方法生成的IPA在iPhone上无法打开；</p>
<p>7、iTunes上的音乐文件点右键创建ACC版本，再在生成的文件上点右键，在资源管理器上显示，把这个文件的后缀名改为m4r，把这个文件用WinSCP传到/private/var/stash/Ringtones目录里，再把这个文件拖到iTunes上iPhone的铃声里，这样不管你怎么同步，铃声都不会消失，也没有45秒的时间限制；</p>
<p>8、新刷是固件在正确破解了MobileInstallation文件后，但同步进去的破解软件依然无法打开的，请删掉后，同步一个免费的软件；</p>
<p><span id="more-304"></span></p>
<h4>iPhone使用技巧：</h4>
<p>1、来电话时，按一下电源键为静音，再按一下为拒接；</p>
<p>2、锁屏状态，双击Home键可以调出iPod小面版，桌面状态则打开iPod（可在设置－通用－主屏幕按钮里设置）；</p>
<p>3、设置－邮件、通讯录、日历里可以直接导入SIM上联系人；</p>
<p>4、用IPA格式安装的软件的设置有时候不在软件界面，而是将设置项新增加到iPhone的“设置”里；</p>
<p>5、iPod里的视频是可以直接删除的，在文件名上从左往右划一下即可，还有很多地方可以用此方法来删除文件；</p>
<p>6、英文输入时，双击大小写切换键可以锁定大写（设置－通用－键盘里可以设置）；</p>
<p>7、时钟里的计时器里的iPod睡眠模式可以让iPod在指定的时间里关闭；</p>
<p>8、发短信时，按了发送后就可以关掉做别的了，不必等待发送完毕，短信会后台发送直至发送完毕；</p>
<p>9、iTunes里的多媒体文件点击下载后就可以关掉做别的了，它会自动后台下载；</p>
<p>10、打电话时，你可以按掉Home键后，玩点别的不必担心会断线；</p>
<p>11、在查看长列表时，点一下顶上的一条可以快速回到列表顶端，比如Safari、联系人等等；</p>
<p>12、无论什么时候，按住电源键不放，再按一下Home键可以把当前屏幕保存到照片里，在iPhone上的存档目录为/private/var/mobile/Media/DCIM/999APPLE/ ；</p>
<p>注：仅适用于2.0以上固件</p>
<p>13、原装的耳麦除了按一下接听/挂断电话外，在点亮屏幕的状态下可以开启/关闭iPod，按两下可以下一首，按三下可以上一首；</p>
<h4>其他技巧：</h4>
<p>1、重刷固件前，你要备份的东西全部都在这里/private/var/mobile目录下的相关文件中，其中</p>
<p>Library下：AddressBook为电话本、Calendar为日历、CallHistory为通话记录、Mail为电邮、 Notes为备忘录、Safari为收藏夹、SMS为短信；</p>
<p>Media下： DCIM为照相机拍的照片和截屏、Photos为电脑里同步进去的图片、iTunes_Control为音乐、电影、铃声文件；</p>
<p>2、新刷的固件如果遇到一些奇怪的问题，比如照片拍起来空白或者是照片无法保存、备忘录不能保存等，多半是权限的问题，到上述的相应目录改一下权限，直接改为777试一下；</p>
<p>3、IPA安装的软件集中在/private/var/mobile/Applications，但文件名是随机的；</p>
<p>4、/private/var/mobile/Media/iTunes_Control/Music下是iPod里的音乐视频文件，虽然文件名是随机的，但Mp3的ID信息并没有问题，可以复制到任何电脑上正常播放，也可以用批量ID信息编辑器重新整理，几百首歌五分钟就可以修改完；</p>
<p>5、当iPhone通过USB连接到iTunes时，iTunes提示iPhone需要恢复，可尝试请删除/private/var/mobile/Media/iTunes_Control/目录，重启iPhone后再重新连接到iTunes即可.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Te6Rp4YIra_hUr9BwKc1dqD91Ag/0/da"><img src="http://feedads.g.doubleclick.net/~a/Te6Rp4YIra_hUr9BwKc1dqD91Ag/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Te6Rp4YIra_hUr9BwKc1dqD91Ag/1/da"><img src="http://feedads.g.doubleclick.net/~a/Te6Rp4YIra_hUr9BwKc1dqD91Ag/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=-qGxblY1EN4:ezjyCG0rYfc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=-qGxblY1EN4:ezjyCG0rYfc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=-qGxblY1EN4:ezjyCG0rYfc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=-qGxblY1EN4:ezjyCG0rYfc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=-qGxblY1EN4:ezjyCG0rYfc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=-qGxblY1EN4:ezjyCG0rYfc:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/-qGxblY1EN4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/01/09/iphone-skill/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/01/09/iphone-skill/</feedburner:origLink></item>
		<item>
		<title>SSH IPHONE</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/4aj9QhViyHw/</link>
		<comments>http://www.ericbess.com/ericblog/2009/01/07/ssh-iphone/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 15:54:47 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/01/07/ssh-iphone/</guid>
		<description><![CDATA[SSH、SCP和SFTP都是SSH套装软体的组成部分。简单的说，SSH是加密方式的控制台远端登入，全称是Secure Shell，是目前广泛采用的安全登录协议，替代以前不安全的Telnet协议。用SSH可以登录到Unix系统，并使用几乎所有的作业系统功能。如果你熟悉Windows的Remote Desktop，那么可以把SSH想像成命令列方式的Remote Desktop。 SSH包括2个部分，服务端的SSHD（Secure Shell Daemon）和SSH用户端。我们通常所说的用SSH登录到某某主机，指的是用SSH用户端登录到某台主机（该主机运行了SSHD服务端程式）。 SCP是Secure Copy的简称，是用来与远端主机之间进行资料传输的协定，相当于经过加密的Copy命令。 SFTP是用SSH封装过的FTP协议，相当于经过加密的FTP协议，功能与FTP一样，只是传输资料经过加密。 SFTP也有2个部分，服务端的SFTP-Server及SFTP Client。通常所说的用SFTP登录到某台主机，指的是用SFTP用户端登录到某台主机（该主机运行了SFTP-Server服务端程式）。
IPHONE ssh应用
用ssh登录IPHONE MAC OS_UNIX.
iphone OS的核心是unix, ssh登录是unix系统管理的第一项工作，如何实现通过wifi网络的ssh logon IPHONE。
在iphone 上安装openssh for iphone 和BossPrefs。其中openssh是ssd，BossPrefs可获得iphone的本机wifi ip 地址和其现SSD开关。
通过ssh用户端，连iphone ip，iphone 2.1初始root密码是alpine.进入后用passwd改password。
用wifi管理IPHONE 文件系统
在前面基础上，安装WinSCP,就可以以wifi sfpt形式管理上下传你的iphone文件, 摆脱数据线。
这两样工作正是深入了解IPHONE MAC OS的开端。
]]></description>
			<content:encoded><![CDATA[<p><em>SSH、SCP和SFTP都是SSH套装软体的组成部分。简单的说，SSH是加密方式的控制台远端登入，全称是Secure Shell，是目前广泛采用的安全登录协议，替代以前不安全的Telnet协议。用SSH可以登录到Unix系统，并使用几乎所有的作业系统功能。如果你熟悉Windows的Remote Desktop，那么可以把SSH想像成命令列方式的Remote Desktop。 SSH包括2个部分，服务端的SSHD（Secure Shell Daemon）和SSH用户端。我们通常所说的用SSH登录到某某主机，指的是用SSH用户端登录到某台主机（该主机运行了SSHD服务端程式）。 <br />SCP是Secure Copy的简称，是用来与远端主机之间进行资料传输的协定，相当于经过加密的Copy命令。 <br />SFTP是用SSH封装过的FTP协议，相当于经过加密的FTP协议，功能与FTP一样，只是传输资料经过加密。 SFTP也有2个部分，服务端的SFTP-Server及SFTP Client。通常所说的用SFTP登录到某台主机，指的是用SFTP用户端登录到某台主机（该主机运行了SFTP-Server服务端程式）。</em><br />
<h4>IPHONE ssh应用</h4>
<p><strong>用ssh登录IPHONE MAC OS_UNIX.<a href="http://www.ericbess.com/ericblog/wp-content/uploads/2009/01/untitled1.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="172" alt="untitled" src="http://www.ericbess.com/ericblog/wp-content/uploads/2009/01/untitled-thumb.jpg" width="280" align="right" border="0"></a></strong>
<p>iphone OS的核心是unix, ssh登录是unix系统管理的第一项工作，如何实现通过wifi网络的ssh logon IPHONE。
<p>在iphone 上安装openssh for iphone 和BossPrefs。其中openssh是ssd，BossPrefs可获得iphone的本机wifi ip 地址和其现SSD开关。
<p>通过ssh用户端，连iphone ip，iphone 2.1初始root密码是alpine.进入后用passwd改password。
<p><strong>用wifi管理IPHONE 文件系统</strong>
<p>在前面基础上，安装WinSCP,就可以以wifi sfpt形式管理上下传你的iphone文件, 摆脱数据线。
<p><em>这两样工作正是深入了解IPHONE MAC OS的开端。</em></p>

<p><a href="http://feedads.g.doubleclick.net/~a/1WC416LPCf0nTb4SXli34SUGCsU/0/da"><img src="http://feedads.g.doubleclick.net/~a/1WC416LPCf0nTb4SXli34SUGCsU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1WC416LPCf0nTb4SXli34SUGCsU/1/da"><img src="http://feedads.g.doubleclick.net/~a/1WC416LPCf0nTb4SXli34SUGCsU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=4aj9QhViyHw:mUeG_mYxC-s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=4aj9QhViyHw:mUeG_mYxC-s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=4aj9QhViyHw:mUeG_mYxC-s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=4aj9QhViyHw:mUeG_mYxC-s:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=4aj9QhViyHw:mUeG_mYxC-s:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=4aj9QhViyHw:mUeG_mYxC-s:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/4aj9QhViyHw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/01/07/ssh-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/01/07/ssh-iphone/</feedburner:origLink></item>
		<item>
		<title>结婚一周年礼物</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/7BCSzgAIO9o/</link>
		<comments>http://www.ericbess.com/ericblog/2009/01/06/gift/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 21:11:40 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2009/01/08/%e6%88%91%e7%9a%84%e7%bb%93%e5%a9%9a%e4%b8%80%e5%91%a8%e5%b9%b4%e7%a4%bc%e7%89%a9/</guid>
		<description><![CDATA[ 收到Bess的新年礼物，也是我们一周年的礼物：Iphone 3G！
很是吃惊，比较我之前用的，Bess总是为我准备最好的，这是Bess的心意，谢谢你！爱你！
其实我并不对最新电子消费品有什么追求，但当我发现在这个如此时尚的外表下有个开放的心时还是不免兴奋许久。
特别是当我通过wifi SSH连入iPhone的心脏，眼前一亮，知道我看到了什么&#8230;..UNIX !
装上BlogPress for iphone, 拍上照，用iphone写博文真是不一样的感受，发送&#8230;.
那个丑陋的家伙就是我的ex-cellphone
&#8211; Post From Eric iPhone
]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"> 收到Bess的新年礼物，也是我们一周年的礼物：Iphone 3G！<br />
很是吃惊，比较我之前用的，Bess总是为我准备最好的，这是Bess的心意，谢谢你！爱你！<br />
其实我并不对最新电子消费品有什么追求，但当我发现在这个如此时尚的外表下有个开放的心时还是不免兴奋许久。<br />
特别是当我通过wifi SSH连入iPhone的心脏，眼前一亮，知道我看到了什么&#8230;..UNIX !<br />
装上BlogPress for iphone, 拍上照，用iphone写博文真是不一样的感受，发送&#8230;.<br />
那个丑陋的家伙就是我的ex-cellphone<br />
&#8211; Post From Eric iPhone</p>

<p><a href="http://feedads.g.doubleclick.net/~a/_Eh6vmsUJW_P6lFYbrIMYrurTX0/0/da"><img src="http://feedads.g.doubleclick.net/~a/_Eh6vmsUJW_P6lFYbrIMYrurTX0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/_Eh6vmsUJW_P6lFYbrIMYrurTX0/1/da"><img src="http://feedads.g.doubleclick.net/~a/_Eh6vmsUJW_P6lFYbrIMYrurTX0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=7BCSzgAIO9o:6z_abR_L9l4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=7BCSzgAIO9o:6z_abR_L9l4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=7BCSzgAIO9o:6z_abR_L9l4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=7BCSzgAIO9o:6z_abR_L9l4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=7BCSzgAIO9o:6z_abR_L9l4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=7BCSzgAIO9o:6z_abR_L9l4:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/7BCSzgAIO9o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2009/01/06/gift/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2009/01/06/gift/</feedburner:origLink></item>
		<item>
		<title>一套WP系统建立N个博客</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/hkWqHMdCSyg/</link>
		<comments>http://www.ericbess.com/ericblog/2008/12/20/%e4%b8%80%e5%a5%97wp%e7%b3%bb%e7%bb%9f%e5%bb%ba%e7%ab%8bn%e4%b8%aa%e5%8d%9a%e5%ae%a2/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 16:40:46 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[网站技术]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/12/20/%e4%b8%80%e5%a5%97wp%e7%b3%bb%e7%bb%9f%e5%bb%ba%e7%ab%8bn%e4%b8%aa%e5%8d%9a%e5%ae%a2/</guid>
		<description><![CDATA[WP本身并不支持多个站点，因此,当你想要建立多个 wp 博客的时候你就要安装多个wp 系统,维护起来也比较麻烦。网上看到的一个很好的设想，应该是可行的,可以在一个wp系统上建立多个博客，不过应该还有很多细节要考虑，还然为什么还有个MU。不管如何还是个很牛的想法。总结一下，什么时候试验一下。原理很简单,wp使用数据库管理数据，因此,如果你想要在一个WP系统中,针对不同的访问者请求,来访问不同的数据库（或者同一个数据库里面的不同数据），那么就很容易实现这一功能在wp-config.php里面有加了这样一段：

?View Code PHP1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if&#40;$_SERVER&#91;&#34;HTTP_HOST&#34;&#93;==&#34;eric.ericbess.com&#34;&#41;&#123;
  define&#40;'DB_NAME', 'ericbess'&#41;;
  define&#40;'DB_USER', 'eric'&#41;;
  define&#40;'DB_PASSWORD', '***'&#41;;
  define&#40;'DB_HOST', 'localhost'&#41;;
  define&#40;'DB_CHARSET', 'utf8'&#41;;
  define&#40;'DB_COLLATE', ''&#41;;
  $table_prefix  = 'eric_';
  define &#40;'WPLANG', 'zh_CN'&#41;;
&#125;else if&#40;$_SERVER&#91;&#34;HTTP_HOST&#34;&#93;==&#34;bess.ericbess.com&#34;&#41;&#123;
  define&#40;'DB_NAME', 'ericbess'&#41;;
  define&#40;'DB_USER', 'bess'&#41;;
  define&#40;'DB_PASSWORD', '***'&#41;;
  define&#40;'DB_HOST', 'localhost'&#41;;
  define&#40;'DB_CHARSET', 'utf8'&#41;;
  define&#40;'DB_COLLATE', ''&#41;;
  $table_prefix  [...]]]></description>
			<content:encoded><![CDATA[<p>WP本身并不支持多个站点，因此,当你想要建立多个 wp 博客的时候你就要安装多个wp 系统,维护起来也比较麻烦。网上看到的一个很好的设想，应该是可行的,可以在一个wp系统上建立多个博客，不过应该还有很多细节要考虑，还然为什么还有个MU。不管如何还是个很牛的想法。总结一下，什么时候试验一下。<br />原理很简单,wp使用数据库管理数据，因此,如果你想要在一个WP系统中,针对不同的访问者请求,来访问不同的数据库（或者同一个数据库里面的不同数据），那么就很容易实现这一功能<br />在wp-config.php里面有加了这样一段：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p296code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2962"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p296code2"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_HOST&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;eric.ericbess.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ericbess'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_USER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'eric'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_PASSWORD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'***'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_HOST'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_CHARSET'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_COLLATE'</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: #000088;">$table_prefix</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'eric_'</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WPLANG'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'zh_CN'</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: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_HOST&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;bess.ericbess.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ericbess'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_USER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bess'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_PASSWORD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'***'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_HOST'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_CHARSET'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_COLLATE'</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: #000088;">$table_prefix</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'bess_'</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WPLANG'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'zh_CN'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>很明显，这个配置文件会根据不同的$_SERVER["HTTP_HOST"]来给出不同的数据库表的配置，一个数据表的前缀是 bess_ 而另外一个是eric_，就算在同一个数据库里面也不会冲突<br />各自有了独立的数据库配置，在同一个优化好的Wordpress系统下能互不干扰的运行起来，再加上不同的主题风格、和插件，各自选择性的使用.</p>
<h4>注意事项</h4>
<ol>
<li>所有插件的数据表设计都注意加前缀：$table_name = $wpdb-&gt;prefix . &#8220;plugin_table_name&#8221;; （其实大部分插件开发都这么做，现在体现出好处来了）</li>
<li>子域名绑定wp（不能做路径跳转）:名字型虚拟主机/rewrite(不知是可行否)</li>
<li>给数据库建控制帐号：（高安全，可选）<br />mysql&gt; grant select,insert,update,delete on ericbess.eric_ to eric@&#8221;%&#8221; Identified by &#8220;eric_password&#8221;; <br />mysql&gt; grant select,insert,update,delete on ericbess.bess_ to bess@&#8221;%&#8221; Identified by &#8220;bess_password&#8221;; </li>
</ol>
<p><em>以上设想未经测试，需测试论证可行性！</em></p>

<p><a href="http://feedads.g.doubleclick.net/~a/MOHQWRA1TcGQfbm_FYsVTXMtrqE/0/da"><img src="http://feedads.g.doubleclick.net/~a/MOHQWRA1TcGQfbm_FYsVTXMtrqE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/MOHQWRA1TcGQfbm_FYsVTXMtrqE/1/da"><img src="http://feedads.g.doubleclick.net/~a/MOHQWRA1TcGQfbm_FYsVTXMtrqE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=hkWqHMdCSyg:HgDoKQfWpjo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=hkWqHMdCSyg:HgDoKQfWpjo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=hkWqHMdCSyg:HgDoKQfWpjo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=hkWqHMdCSyg:HgDoKQfWpjo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=hkWqHMdCSyg:HgDoKQfWpjo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=hkWqHMdCSyg:HgDoKQfWpjo:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/hkWqHMdCSyg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/12/20/%e4%b8%80%e5%a5%97wp%e7%b3%bb%e7%bb%9f%e5%bb%ba%e7%ab%8bn%e4%b8%aa%e5%8d%9a%e5%ae%a2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/12/20/%e4%b8%80%e5%a5%97wp%e7%b3%bb%e7%bb%9f%e5%bb%ba%e7%ab%8bn%e4%b8%aa%e5%8d%9a%e5%ae%a2/</feedburner:origLink></item>
		<item>
		<title>宋鸿兵著作《货币战争》中罗斯切尔德家族历史</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/Rks2rwyJf5A/</link>
		<comments>http://www.ericbess.com/ericblog/2008/12/12/rothschild/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 08:44:42 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Reading]]></category>
		<category><![CDATA[财金与投资]]></category>
		<category><![CDATA[品牌作用]]></category>
		<category><![CDATA[国际化]]></category>
		<category><![CDATA[新名词]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/12/12/%e5%ae%8b%e9%b8%bf%e5%85%b5%e8%91%97%e4%bd%9c%e3%80%8a%e8%b4%a7%e5%b8%81%e6%88%98%e4%ba%89%e3%80%8b%e4%b8%ad%e7%bd%97%e6%96%af%e5%88%87%e5%b0%94%e5%be%b7%e5%ae%b6%e6%97%8f%e5%8e%86%e5%8f%b2/</guid>
		<description><![CDATA[
 　　说到“红盾世家”，很多人乍一看，觉得没有听说过，顶多会有一些猜想：红是不是代表血啊，红盾大概就是沾满鲜血的或血淋淋的盾牌吧，也许是中外某个享有盛名但我尚不知道的军人或将军世家，或是世代有人从军或当将军的家族。
　　不过，我要是说“罗斯切尔德家族”(或称“罗斯柴尔德家族”)，很多人就会恍然大悟：就是宋鸿兵的《货币战争》中提到的世界第一财富家族，控制了30万亿美元的资产，比比尔·盖茨还要多；据说包括两次世界大战和多个美国总统被刺的许多历史事件都是由其背后操纵的；罗斯切尔德家族简直就是世界政治经济的幕后推手，简直就是为了获取终极财富和权力躲在阴暗的角落里无情无耻的耍着坏心眼的“大阴谋家”！
　　Rothschild家族的起源是德国犹太人，这个词是德语，roth即英文中的red，child即英文中的shield，读音非常接近，为“希尔德”，合起来的意思是“红盾”。
　　让我们深入历史和现实，看看红盾世家的肇始和兴衰沉浮，感受一下这个享有盛名的财富世家的真实传奇。
横空出世
　　红盾世家的草创者为梅耶(Mayer Amschel Rothschild)。1744年，他生于德国法兰克福的犹太聚居区，其所属的家族到他这一代已经在这里繁衍生息二百多年了。梅耶年轻时去汉诺威银行学习了金融实务——这也是在欧洲的犹太人能从事的少数传统职业之一。
　　梅耶20岁时回到法兰克福，从事经营包括古钱币在内的古董业。据说，他总是在自己的店门口放置一块红色盾牌——不知什么目的，也许是纯粹出于对这一徽章的喜爱，也许是体现了品牌的意识——反正，久而久之，这块红色盾牌成为梅耶古董店甚至其本人的logo，附近的人图方便把梅耶一家称为红盾。
　　当时欧洲的王公贵族有一项雅好：收藏古钱币。如果能在古钱币市场做大，收获的可不仅仅是财富。梅耶投入了巨大的精力和热忱，费尽心力，编写了《古钱币手册》，内里详加解说，又分寄给各地的王公贵族，广泛撒网，以冀得到垂青。只要有某个有权有势的贵族通过这本书看上了梅耶，他就能大发其达了。
　　梅耶的努力得到了黑森公爵的响应。黑森是大富大贵的人物，身家在当时可是天文数字，其生意是出租军队替别人打仗。黑森最大的客户是英国，因为当时英国的北美殖民地爆发了独立战争，英国亟需军队弹压。钓到了大鱼的梅耶，半卖半送，向黑森出售了他持有的大量珍贵古徽章、古钱币，并极力帮助黑森搜集古钱币，又发掘和创造各种机会帮公爵赚钱。
　　梅耶花在黑森身上的巨额工本没有白费，他取得了黑森的信任和友谊。后来，黑森为了躲避拿破仑的打击，离开法兰克福、亡命丹麦时，留下了300万英镑交给他保管，这笔钱是英国使用黑森部队的租金。这笔巨款，令梅耶一举成为当时欧洲首位国际银行家。再后来，梅耶将那300万英镑连本带息交还给了黑森。这给当时已经崭露头角的红盾家族，做了一次效果奇佳的企业品牌价值证明：我们信誉至上，钱放在我们这里安全和回报两不误。
　　梅耶的投资手法可圈可点。他一旦有了接近某个对其有巨大潜在价值的大人物，就会不惜代价、无微不至地为其提供服务、创造价值；当与对方建立了牢不可破的深厚感情和关系后，再把这种感情和关系择机“套现”，到那时候，潜在价值就变成了现实价值，回报比一般的生意高多了。
　　不仅如此，梅耶还充分认识到了信息的价值。他花费心力，逐渐建立起了一个横跨全欧、本家族专用的信息传递网络，具备了在许多重要事件上比别人早知道一些信息的能力。随着红盾家族生意做大，结识的权贵越来越多，重要的信息源也越来越多，因此，这个信息传递网络，既迅速又可靠。据说，英国的维多利亚女王很多时候宁愿用梅耶家的信使来投递她的信件。

一花五枝
　　梅耶膝下有五子，依次为：阿姆希洛(Amschel Mayer Rothschild)、所罗门(Salomon Mayer Rothschild )、纳坦(Nathan Mayer Rothschild )、卡曼(Calmann Mayer Rothschild)和詹姆斯(James Mayer Rothschild)。有道是“虎父无犬子”，红盾家族没有一个是孬种。
　　最有才干的是三子纳坦，他于1804年只身来到伦敦闯世界，先是做纺织品生意。当时欧洲大陆拿破仑势头正猛、麾下大军所向披靡。德意志的许多贵族待不下去了，纷纷流亡英国，其中有法兰克福的威廉伯爵。为了使自己的财产保值增值，威廉委托纳坦购买了大量英国债券。纳坦以敏锐的触觉，感到这个生意大有赚头，趁势自己也做起了债券、股票，相当于券商和投行的业务。纳坦的能力获得了丰厚的回报，迅速积累了财富，成为伦敦金融界的大亨。后来，他又抓住机会利用自己的财富向英国政府“输诚”，与许多军政要人走得很近。
　　纳坦在英国的成功，启发了父亲梅耶。红盾家族开始了在欧洲各地建立罗斯切尔德家族银行的分支行，形成了“一花开五枝”之势：
　　梅耶和长子阿姆希洛坐镇法兰克福分行；二子所罗门掌控维也纳分行；三子纳坦领导伦敦分行；四子卡曼分管那不勒斯分行；幼子詹姆斯主理巴黎分行。这样，一个庞大的金融商业帝国就初具雏形了。
　　三子纳坦的惊人手笔还在后面。1815年6月18日，反法联军与拿破仑在比利时的滑铁卢进行大决战。谁胜谁负，虽然没有人有能力预知，但如果有人能比别人早上一步知道结果，他就赚个盆满钵满。如果反法联军赢了，英国国债的行情就会看涨，做多就行；反之，做空就行。
　　红盾家族的信息传递网络这时发挥了作用。大陆那边有人通过专门渠道领先知道了拿破仑战败的消息，赶紧从荷兰的鹿特丹港乘坐快船，渡过海峡抵达英国，马不停蹄把消息送到纳坦手中。纳坦立即快马加鞭赶往伦敦。他知道这个消息，比英国政府还早了几个小时，这几个小时的时间差意味着大把大把的金钱，可见，“时间就是金钱”绝非应景的话。
　　纳坦来到伦敦证券交易所自己的固定席位前，做出了一个惊人的决定：抛售英国国债。这个情况落到在场每一个投资者的眼里。大家都在想：纳坦抛了，英国肯定战败了，我也得赶紧割肉斩仓。恐慌性的抛售开始了，英国国债的价格暴跌。纳坦觉得波谷已经到了，暗中给自己的代理人发了指令，代理人无限吃进。杀跌的人大感困惑，连呼看不懂。不久，捷报传来，英国国债价格一路飙升。短短几个小时之内，纳坦获利数百万英镑。
　　就这样，梅耶的五个儿子依凭家族的强大资源，发挥各自的经营天赋，把罗斯切尔德家族的生意和财富不断地扩展。他们在各地开办银行，包揽商业银行和投资银行的业务，又兴办铁路、通讯、钢铁、煤炭、石油等各种实业，成为了威名赫赫的财富家族。
真实Vs传闻
　　红盾家族和许许多多犹太财富家族一样，以赚钱为要务，相信“金钱一旦呛啷作响，坏话就戛然而止”。梅耶留下家训，要子孙坚持家族的和谐，“只要你们团结一致，你们就所向无敌；你们分手之时，就是你们失去繁荣的开始”。
　　红盾家族的致富之道，无非是懂政治、知经济。不问政治，眼中只有赚钱，并不能保证赚钱，也不能保证守住赚来的钱；会玩政治，能赚大钱，也能守住赚来的钱。权势、关系本身就是能带来收入的资产。红盾家族广泛结交权贵，建立私交，甚至不惜与权贵家族联姻，既积累了财富，也壮大了家族，做到了“财丁两旺”。
　　红盾家族坚持个人、家族和民族利益上的一致性。纳坦曾拒绝同任何一个拒绝给犹太人公民权的德意志城市做生意。纳坦之子列昂内尔(Lionel Nathan Rothschild)事功不在其父之下，曾借400万英镑的巨款给英国政府购买埃及国王出让的苏伊士运河股票，从而使英国控制了苏伊士运河，列昂内尔·罗斯切尔德一夕之间成为英国举国敬仰的大英雄。列昂内尔当选英国下议院议员。他不愿用基督教方式，而坚持要以犹太教方式用手按《圣经》宣誓，最后这个要求被接受。这是一个异乎寻常的胜利，让长期受歧视和迫害的在欧犹太人受到鼓舞。列昂内尔有一句名言：“我有两大荣誉：第一，我是罗斯切尔德家族的一员；第二，我是一个犹太人。”充分表明了他乃至红盾家族世世代代的家族和民族利益取向。
　　红盾家族与犹太复国主义有着重大联系。在20世纪初，曾向迁往巴勒斯坦的早期犹太移民提供了数百万美元的资金，帮助他们购买土地和生产设备，安居乐业；也积极参与犹太重新建国。英国政府颁布的《贝尔福宣言》，宣称要使巴勒斯坦成为“犹太民族之家”，成为后来以色列建国的蓝图，这个著名的历史性文件，是以英国外交部致罗斯切尔德家族英国支脉的纳坦尼尔·梅耶·罗斯切尔德(Nathaniel Mayer Victor Rothschild)勋爵的名义发表的。
　　红盾家族的犹太家世及与犹太复国主义运动的联系，自然而然成为历次反犹主义的冲击对象。在纳粹统治德国的时代，罗斯切尔德家族德国支脉的许多成员遇难。此外，种种基于反犹主义的以红盾家族为故事主角的阴谋论也大行其道，满足了一部分人对这个家族隐秘的财富和行为的想象。《The Money Masters》及其在中国的翻版《货币战争》，既不是第一个，也不会是最后一个。
　　红盾家族的故事还被搬上了银幕和舞台。1934年好莱坞电影《罗斯切尔德之家》(The House of Rothschild)由George Arliss 和Loretta Young主演，以梅耶的生平为故事的主线。这部电影的若干片段上了纳粹的反犹宣传《外部的犹太人》(Der ewige Jude)。百老汇音乐剧《罗斯切尔德家族》(The Rothschilds)，还获得过1971年 Tony Award 的提名。
　　在法文和希伯来文中，Rothschild都是财富的代名词。那么现在罗斯切尔德家族到底多有钱呢？罗斯切尔德银行集团目前一年的营业额不足百亿美元，盈利不到30亿美元，以10%的利息率算，其资产价值大约300亿美元，不过是汇丰花旗等大银行的一个零头而已。其主要原因是，罗斯切尔德家族在19世纪中期不看好美国的经济，撤销了在美国的所有分行。这在后来看是一个天大的错误，给了美国摩根家族崛起的空间。所以那些宣称罗斯切尔德家族对美国经济多有影响力的阴谋论论调，是多么不着边际。另外，罗斯切尔德家族二战中损失惨重。在纳粹统治和战乱之下，其位于德、法、意的许多资产荡然无存，其欧洲大陆的家族势力所剩无几，保存比较完好的是在英国的资产。
　　家族企业既有其优势，也有其局限。仅仅依靠家族自有资金想要在现在的世界取得过去那样的成功和辉煌几乎是不可能的。现在的金融市场是全球化的、高度竞争的，想要以任何方式操纵金融市场牟利越来越不容易。最近美国的次级债危机中，花旗、美林证券和瑞银都损失惨重，如果金融市场是稳赚不赔的话，花旗和美林政权的CEO就不会黯然去职了。
　　红盾世家过去很辉煌，现在还在守成。看来是，君子之泽，五世不斩。这确实很牛，但绝没有阴谋论者所宣称的那样牛。
　　红盾家族的致富之道，无非是懂政治、知经济。不问政治，眼中只有赚钱，并不能保证赚钱，也不能保证守住赚来的钱；会玩政治，能赚大钱，也能守住赚来的钱。权势、关系本身就是能带来收入的资产。
]]></description>
			<content:encoded><![CDATA[<p><img src="http://club.jinti.com/UploadFiles/member/2875226/200811201046392838.jpg" alt="" width="286" height="252" align="right" /></p>
<p> 　　说到“红盾世家”，很多人乍一看，觉得没有听说过，顶多会有一些猜想：红是不是代表血啊，红盾大概就是沾满鲜血的或血淋淋的盾牌吧，也许是中外某个享有盛名但我尚不知道的军人或将军世家，或是世代有人从军或当将军的家族。</p>
<p>　　不过，我要是说“罗斯切尔德家族”(或称“罗斯柴尔德家族”)，很多人就会恍然大悟：就是宋鸿兵的《货币战争》中提到的世界第一财富家族，控制了30万亿美元的资产，比比尔·盖茨还要多；据说包括两次世界大战和多个美国总统被刺的许多历史事件都是由其背后操纵的；罗斯切尔德家族简直就是世界政治经济的幕后推手，简直就是为了获取终极财富和权力躲在阴暗的角落里无情无耻的耍着坏心眼的“大阴谋家”！</p>
<p>　　Rothschild家族的起源是德国犹太人，这个词是德语，roth即英文中的red，child即英文中的shield，读音非常接近，为“希尔德”，合起来的意思是“红盾”。</p>
<p>　　让我们深入历史和现实，看看红盾世家的肇始和兴衰沉浮，感受一下这个享有盛名的财富世家的真实传奇。</p>
<h4>横空出世</h4>
<p>　　红盾世家的草创者为梅耶(Mayer Amschel Rothschild)。1744年，他生于德国法兰克福的犹太聚居区，其所属的家族到他这一代已经在这里繁衍生息二百多年了。梅耶年轻时去汉诺威银行学习了金融实务——这也是在欧洲的犹太人能从事的少数传统职业之一。</p>
<p>　　梅耶20岁时回到法兰克福，从事经营包括古钱币在内的古董业。据说，他总是在自己的店门口放置一块红色盾牌——不知什么目的，也许是纯粹出于对这一徽章的喜爱，也许是体现了品牌的意识——反正，久而久之，这块红色盾牌成为梅耶古董店甚至其本人的logo，附近的人图方便把梅耶一家称为红盾。</p>
<p>　　当时欧洲的王公贵族有一项雅好：收藏古钱币。如果能在古钱币市场做大，收获的可不仅仅是财富。梅耶投入了巨大的精力和热忱，费尽心力，编写了《古钱币手册》，内里详加解说，又分寄给各地的王公贵族，广泛撒网，以冀得到垂青。只要有某个有权有势的贵族通过这本书看上了梅耶，他就能大发其达了。</p>
<p>　　梅耶的努力得到了黑森公爵的响应。黑森是大富大贵的人物，身家在当时可是天文数字，其生意是出租军队替别人打仗。黑森最大的客户是英国，因为当时英国的北美殖民地爆发了独立战争，英国亟需军队弹压。钓到了大鱼的梅耶，半卖半送，向黑森出售了他持有的大量珍贵古徽章、古钱币，并极力帮助黑森搜集古钱币，又发掘和创造各种机会帮公爵赚钱。</p>
<p>　　梅耶花在黑森身上的巨额工本没有白费，他取得了黑森的信任和友谊。后来，黑森为了躲避拿破仑的打击，离开法兰克福、亡命丹麦时，留下了300万英镑交给他保管，这笔钱是英国使用黑森部队的租金。这笔巨款，令梅耶一举成为当时欧洲首位国际银行家。再后来，梅耶将那300万英镑连本带息交还给了黑森。这给当时已经崭露头角的红盾家族，做了一次效果奇佳的企业品牌价值证明：我们信誉至上，钱放在我们这里安全和回报两不误。</p>
<p>　　梅耶的投资手法可圈可点。他一旦有了接近某个对其有巨大潜在价值的大人物，就会不惜代价、无微不至地为其提供服务、创造价值；当与对方建立了牢不可破的深厚感情和关系后，再把这种感情和关系择机“套现”，到那时候，潜在价值就变成了现实价值，回报比一般的生意高多了。</p>
<p>　　不仅如此，梅耶还充分认识到了信息的价值。他花费心力，逐渐建立起了一个横跨全欧、本家族专用的信息传递网络，具备了在许多重要事件上比别人早知道一些信息的能力。随着红盾家族生意做大，结识的权贵越来越多，重要的信息源也越来越多，因此，这个信息传递网络，既迅速又可靠。据说，英国的维多利亚女王很多时候宁愿用梅耶家的信使来投递她的信件。</p>
<p><span id="more-295"></span></p>
<h4>一花五枝</h4>
<p>　　梅耶膝下有五子，依次为：阿姆希洛(Amschel Mayer Rothschild)、所罗门(Salomon Mayer Rothschild )、纳坦(Nathan Mayer Rothschild )、卡曼(Calmann Mayer Rothschild)和詹姆斯(James Mayer Rothschild)。有道是“虎父无犬子”，红盾家族没有一个是孬种。</p>
<p>　　最有才干的是三子纳坦，他于1804年只身来到伦敦闯世界，先是做纺织品生意。当时欧洲大陆拿破仑势头正猛、麾下大军所向披靡。德意志的许多贵族待不下去了，纷纷流亡英国，其中有法兰克福的威廉伯爵。为了使自己的财产保值增值，威廉委托纳坦购买了大量英国债券。纳坦以敏锐的触觉，感到这个生意大有赚头，趁势自己也做起了债券、股票，相当于券商和投行的业务。纳坦的能力获得了丰厚的回报，迅速积累了财富，成为伦敦金融界的大亨。后来，他又抓住机会利用自己的财富向英国政府“输诚”，与许多军政要人走得很近。</p>
<p>　　纳坦在英国的成功，启发了父亲梅耶。红盾家族开始了在欧洲各地建立罗斯切尔德家族银行的分支行，形成了“一花开五枝”之势：</p>
<p>　　梅耶和长子阿姆希洛坐镇法兰克福分行；二子所罗门掌控维也纳分行；三子纳坦领导伦敦分行；四子卡曼分管那不勒斯分行；幼子詹姆斯主理巴黎分行。这样，一个庞大的金融商业帝国就初具雏形了。</p>
<p>　　三子纳坦的惊人手笔还在后面。1815年6月18日，反法联军与拿破仑在比利时的滑铁卢进行大决战。谁胜谁负，虽然没有人有能力预知，但如果有人能比别人早上一步知道结果，他就赚个盆满钵满。如果反法联军赢了，英国国债的行情就会看涨，做多就行；反之，做空就行。</p>
<p>　　红盾家族的信息传递网络这时发挥了作用。大陆那边有人通过专门渠道领先知道了拿破仑战败的消息，赶紧从荷兰的鹿特丹港乘坐快船，渡过海峡抵达英国，马不停蹄把消息送到纳坦手中。纳坦立即快马加鞭赶往伦敦。他知道这个消息，比英国政府还早了几个小时，这几个小时的时间差意味着大把大把的金钱，可见，“时间就是金钱”绝非应景的话。</p>
<p>　　纳坦来到伦敦证券交易所自己的固定席位前，做出了一个惊人的决定：抛售英国国债。这个情况落到在场每一个投资者的眼里。大家都在想：纳坦抛了，英国肯定战败了，我也得赶紧割肉斩仓。恐慌性的抛售开始了，英国国债的价格暴跌。纳坦觉得波谷已经到了，暗中给自己的代理人发了指令，代理人无限吃进。杀跌的人大感困惑，连呼看不懂。不久，捷报传来，英国国债价格一路飙升。短短几个小时之内，纳坦获利数百万英镑。</p>
<p>　　就这样，梅耶的五个儿子依凭家族的强大资源，发挥各自的经营天赋，把罗斯切尔德家族的生意和财富不断地扩展。他们在各地开办银行，包揽商业银行和投资银行的业务，又兴办铁路、通讯、钢铁、煤炭、石油等各种实业，成为了威名赫赫的财富家族。</p>
<h4>真实Vs传闻</h4>
<p>　　红盾家族和许许多多犹太财富家族一样，以赚钱为要务，相信“金钱一旦呛啷作响，坏话就戛然而止”。梅耶留下家训，要子孙坚持家族的和谐，“只要你们团结一致，你们就所向无敌；你们分手之时，就是你们失去繁荣的开始”。</p>
<p>　　红盾家族的致富之道，无非是懂政治、知经济。不问政治，眼中只有赚钱，并不能保证赚钱，也不能保证守住赚来的钱；会玩政治，能赚大钱，也能守住赚来的钱。权势、关系本身就是能带来收入的资产。红盾家族广泛结交权贵，建立私交，甚至不惜与权贵家族联姻，既积累了财富，也壮大了家族，做到了“财丁两旺”。</p>
<p>　　红盾家族坚持个人、家族和民族利益上的一致性。纳坦曾拒绝同任何一个拒绝给犹太人公民权的德意志城市做生意。纳坦之子列昂内尔(Lionel Nathan Rothschild)事功不在其父之下，曾借400万英镑的巨款给英国政府购买埃及国王出让的苏伊士运河股票，从而使英国控制了苏伊士运河，列昂内尔·罗斯切尔德一夕之间成为英国举国敬仰的大英雄。列昂内尔当选英国下议院议员。他不愿用基督教方式，而坚持要以犹太教方式用手按《圣经》宣誓，最后这个要求被接受。这是一个异乎寻常的胜利，让长期受歧视和迫害的在欧犹太人受到鼓舞。列昂内尔有一句名言：“我有两大荣誉：第一，我是罗斯切尔德家族的一员；第二，我是一个犹太人。”充分表明了他乃至红盾家族世世代代的家族和民族利益取向。</p>
<p>　　红盾家族与犹太复国主义有着重大联系。在20世纪初，曾向迁往巴勒斯坦的早期犹太移民提供了数百万美元的资金，帮助他们购买土地和生产设备，安居乐业；也积极参与犹太重新建国。英国政府颁布的《贝尔福宣言》，宣称要使巴勒斯坦成为“犹太民族之家”，成为后来以色列建国的蓝图，这个著名的历史性文件，是以英国外交部致罗斯切尔德家族英国支脉的纳坦尼尔·梅耶·罗斯切尔德(Nathaniel Mayer Victor Rothschild)勋爵的名义发表的。</p>
<p>　　红盾家族的犹太家世及与犹太复国主义运动的联系，自然而然成为历次反犹主义的冲击对象。在纳粹统治德国的时代，罗斯切尔德家族德国支脉的许多成员遇难。此外，种种基于反犹主义的以红盾家族为故事主角的阴谋论也大行其道，满足了一部分人对这个家族隐秘的财富和行为的想象。《The Money Masters》及其在中国的翻版《货币战争》，既不是第一个，也不会是最后一个。</p>
<p>　　红盾家族的故事还被搬上了银幕和舞台。1934年好莱坞电影《罗斯切尔德之家》(The House of Rothschild)由George Arliss 和Loretta Young主演，以梅耶的生平为故事的主线。这部电影的若干片段上了纳粹的反犹宣传《外部的犹太人》(Der ewige Jude)。百老汇音乐剧《罗斯切尔德家族》(The Rothschilds)，还获得过1971年 Tony Award 的提名。</p>
<p>　　在法文和希伯来文中，Rothschild都是财富的代名词。那么现在罗斯切尔德家族到底多有钱呢？罗斯切尔德银行集团目前一年的营业额不足百亿美元，盈利不到30亿美元，以10%的利息率算，其资产价值大约300亿美元，不过是汇丰花旗等大银行的一个零头而已。其主要原因是，罗斯切尔德家族在19世纪中期不看好美国的经济，撤销了在美国的所有分行。这在后来看是一个天大的错误，给了美国摩根家族崛起的空间。所以那些宣称罗斯切尔德家族对美国经济多有影响力的阴谋论论调，是多么不着边际。另外，罗斯切尔德家族二战中损失惨重。在纳粹统治和战乱之下，其位于德、法、意的许多资产荡然无存，其欧洲大陆的家族势力所剩无几，保存比较完好的是在英国的资产。</p>
<p>　　家族企业既有其优势，也有其局限。仅仅依靠家族自有资金想要在现在的世界取得过去那样的成功和辉煌几乎是不可能的。现在的金融市场是全球化的、高度竞争的，想要以任何方式操纵金融市场牟利越来越不容易。最近美国的次级债危机中，花旗、美林证券和瑞银都损失惨重，如果金融市场是稳赚不赔的话，花旗和美林政权的CEO就不会黯然去职了。</p>
<p>　　红盾世家过去很辉煌，现在还在守成。看来是，君子之泽，五世不斩。这确实很牛，但绝没有阴谋论者所宣称的那样牛。</p>
<p>　　红盾家族的致富之道，无非是懂政治、知经济。不问政治，眼中只有赚钱，并不能保证赚钱，也不能保证守住赚来的钱；会玩政治，能赚大钱，也能守住赚来的钱。权势、关系本身就是能带来收入的资产。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/xHmIbfC1oB1JivQtVyC87tkmHEE/0/da"><img src="http://feedads.g.doubleclick.net/~a/xHmIbfC1oB1JivQtVyC87tkmHEE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/xHmIbfC1oB1JivQtVyC87tkmHEE/1/da"><img src="http://feedads.g.doubleclick.net/~a/xHmIbfC1oB1JivQtVyC87tkmHEE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Rks2rwyJf5A:AabkTejlF4M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Rks2rwyJf5A:AabkTejlF4M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=Rks2rwyJf5A:AabkTejlF4M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Rks2rwyJf5A:AabkTejlF4M:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Rks2rwyJf5A:AabkTejlF4M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Rks2rwyJf5A:AabkTejlF4M:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/Rks2rwyJf5A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/12/12/rothschild/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/12/12/rothschild/</feedburner:origLink></item>
		<item>
		<title>这个wii驾船游戏玩过吗！</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/Nd_9zta8sWE/</link>
		<comments>http://www.ericbess.com/ericblog/2008/12/01/wii_boa/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 13:34:43 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/12/01/%e8%bf%99%e4%b8%aawii%e9%a9%be%e8%88%b9%e6%b8%b8%e6%88%8f%e7%8e%a9%e8%bf%87%e5%90%97%ef%bc%81/</guid>
		<description><![CDATA[ 
这位老兄采用Arduino 平台，透过他来控制两颗靠高尔夫球车电池驱动的马达，另外再加上一些奇奇怪怪的零件，就完成了这个以 nunchuck 操作控制的独木舟。整艘船的续航力达 6 至 8 小时，同时航速约每小时四英哩，这样在湖面让微风轻抚，看来是再爽快也不过了。

]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2008/12/wii-nunchuck-canoe.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="309" alt="wii-nunchuck-canoe" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/12/wii-nunchuck-canoe-thumb.jpg" width="411" border="0"></a> </p>
<p>这位老兄采用Arduino 平台，透过他来控制两颗靠高尔夫球车电池驱动的马达，另外再加上一些奇奇怪怪的零件，就完成了这个以 nunchuck 操作控制的独木舟。整艘船的续航力达 6 至 8 小时，同时航速约每小时四英哩，这样在湖面让微风轻抚，看来是再爽快也不过了。</p>
<p><embed src="http://www.youtube.com/v/viX6kC9C0Yc&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en&amp;feature=player_embedded&amp;fs=1" width="425" height="344" type="application/x-shockwave-flash" allowfullscreen="true"></embed></p>

<p><a href="http://feedads.g.doubleclick.net/~a/6X-Sk_t-ba0H-kbsxyzRJhRn48w/0/da"><img src="http://feedads.g.doubleclick.net/~a/6X-Sk_t-ba0H-kbsxyzRJhRn48w/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/6X-Sk_t-ba0H-kbsxyzRJhRn48w/1/da"><img src="http://feedads.g.doubleclick.net/~a/6X-Sk_t-ba0H-kbsxyzRJhRn48w/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Nd_9zta8sWE:75NZk-Y2GAA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Nd_9zta8sWE:75NZk-Y2GAA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=Nd_9zta8sWE:75NZk-Y2GAA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Nd_9zta8sWE:75NZk-Y2GAA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Nd_9zta8sWE:75NZk-Y2GAA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=Nd_9zta8sWE:75NZk-Y2GAA:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/Nd_9zta8sWE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/12/01/wii_boa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/12/01/wii_boa/</feedburner:origLink></item>
		<item>
		<title>wii还能这么玩</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/wjx0GFX1gUs/</link>
		<comments>http://www.ericbess.com/ericblog/2008/12/01/wii_arduino/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 08:24:13 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/12/01/wii%e8%bf%98%e8%83%bd%e8%bf%99%e4%b9%88%e7%8e%a9/</guid>
		<description><![CDATA[用wii左手控制器Nunchunk+arduino实现监控跟踪。不明白在说什么吧！先看看这个：

玩wii的都知道wii左手中有个三坐标感应器，可以感应控制器的三维运动。作者利用一个arduino模块和一个摄像头及拖架。DIY的监控跟踪超灵活成本还低，中国的警用直升机应该都配一个。
发明者： http://www.ideavirus.it&#160; YouTube上有很多这样的DIY，什么时候国人也能这么玩WII呀！！
这个系统的关键是arduino。
什么是arduino
 &#160; 
Arduino是一个开放的硬件平台，包括一个简单易用的I/O电路板，以及一个基于Eclipse的软件开发环境。Arduino即可以被用来开发能够独立运行，并具备一定互动性的电子作品，也可以被用来开发与PC相连接的外围装置，这些装甚至还能够与运行在PC上的软件（如Flash，Max/Msp，Director，Processing等）进行沟通。 Arduino硬件电路板可以自行焊接组装，也可以购买已经组装好的，软件则可以从Arduino网站免费下载使用。其中硬件参考电路是以CC（Creative Commons）的形式提供授权。

Arduino 官方网站 http://arduino.cc/Arduino 台湾网站 http://arduino.tw/Arduino 中国网站 http://arduino.cn/arduinocn组http://groups.google.com/group/arduinocn

]]></description>
			<content:encoded><![CDATA[<p>用wii左手控制器Nunchunk+arduino实现监控跟踪。不明白在说什么吧！先看看这个：</p>
<p><embed src="http://www.youtube.com/v/MD_-YnFZFP8&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;feature=player_embedded&amp;fs=1" width="425" height="344" type="application/x-shockwave-flash" allowfullscreen="true"></p>
<p>玩wii的都知道wii左手中有个三坐标感应器，可以感应控制器的三维运动。作者利用一个arduino模块和一个摄像头及拖架。DIY的监控跟踪超灵活成本还低，中国的警用直升机应该都配一个。</p>
<p>发明者： <a href="http://www.ideavirus.it">http://www.ideavirus.it</a>&nbsp; YouTube上有很多这样的DIY，什么时候国人也能这么玩WII呀！！</p>
<p>这个系统的关键是arduino。</p>
<h4>什么是arduino</h4>
<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2008/12/arduino.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="171" alt="arduino" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/12/arduino-thumb.jpg" width="244" border="0"></a> <a href="http://www.ericbess.com/ericblog/wp-content/uploads/2008/12/fritzing0005vista.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="208" alt="fritzing0005vista" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/12/fritzing0005vista-thumb.png" width="244" border="0"></a>&nbsp; </p>
<p>Arduino是一个开放的硬件平台，包括一个简单易用的I/O电路板，以及一个基于Eclipse的软件开发环境。Arduino即可以被用来开发能够独立运行，并具备一定互动性的电子作品，也可以被用来开发与PC相连接的外围装置，这些装甚至还能够与运行在PC上的软件（如Flash，Max/Msp，Director，Processing等）进行沟通。 <br />Arduino硬件电路板可以自行焊接组装，也可以购买已经组装好的，软件则可以从Arduino网站免费下载使用。其中硬件参考电路是以CC（Creative Commons）的形式提供授权。
<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2008/12/fschemerawsmall.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="83" alt="fschemerawsmall" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/12/fschemerawsmall-thumb.jpg" width="244" border="0"></a></p>
<p>Arduino 官方网站 <a href="http://arduino.cc/">http://arduino.cc/</a><br />Arduino 台湾网站 <a href="http://arduino.tw/">http://arduino.tw/</a><br />Arduino 中国网站 <a href="http://arduino.cn/">http://arduino.cn/</a><br />arduinocn组<a href="http://groups.google.com/group/arduinocn">http://groups.google.com/group/arduinocn</a></p>
<p><a href="http://www.douban.com/register?reason=join-group"></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/b2VGUlMINohg8TwraRxqKxUWy5c/0/da"><img src="http://feedads.g.doubleclick.net/~a/b2VGUlMINohg8TwraRxqKxUWy5c/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/b2VGUlMINohg8TwraRxqKxUWy5c/1/da"><img src="http://feedads.g.doubleclick.net/~a/b2VGUlMINohg8TwraRxqKxUWy5c/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wjx0GFX1gUs:5U5Jzx50IjE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wjx0GFX1gUs:5U5Jzx50IjE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=wjx0GFX1gUs:5U5Jzx50IjE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wjx0GFX1gUs:5U5Jzx50IjE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wjx0GFX1gUs:5U5Jzx50IjE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wjx0GFX1gUs:5U5Jzx50IjE:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/wjx0GFX1gUs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/12/01/wii_arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/12/01/wii_arduino/</feedburner:origLink></item>
		<item>
		<title>弱势美元重现日 黄金本色再灿时</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/c7lN6JRNbZ0/</link>
		<comments>http://www.ericbess.com/ericblog/2008/12/01/%e5%bc%b1%e5%8a%bf%e7%be%8e%e5%85%83%e9%87%8d%e7%8e%b0%e6%97%a5-%e9%bb%84%e9%87%91%e6%9c%ac%e8%89%b2%e5%86%8d%e7%81%bf%e6%97%b6/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 05:31:25 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Reading]]></category>
		<category><![CDATA[财金与投资]]></category>
		<category><![CDATA[黄金]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/12/01/%e5%bc%b1%e5%8a%bf%e7%be%8e%e5%85%83%e9%87%8d%e7%8e%b0%e6%97%a5-%e9%bb%84%e9%87%91%e6%9c%ac%e8%89%b2%e5%86%8d%e7%81%bf%e6%97%b6/</guid>
		<description><![CDATA[　　当阿里巴巴和基督山伯爵在山洞里发现金币时，那是真正的硬通货时代，也在我们童年的记忆里刻下了财富的代名词——黄金。围绕黄金的故事与传说自古就不绝于耳，但自从1973年布雷顿森林体系解体、黄金与美元的固定比价关系不复存在以来，黄金如同高贵的公主沦落民间，虽容颜依旧，却不再富贵照人。而围绕黄金由市场定价机制形成，带给全球金融体系的浮动汇率变革才算真正开始。
　　一个有趣的现象是，几十年的市场选择淘汰，若论黄金交易市场的便捷与时区完备，全球其他商品与货币可能还没有出其右者。从伦敦格林威治时间每天早晨8点(北京时间下午4点)开始，然后向纽约、悉尼、东京、香港、上海、迪拜、苏黎世再回到伦敦，一天24小时，各大黄金交易场所能提供不间断的交易机会，存在即合理，为什么人们对黄金交易有如此大的“排场”需求？
双面娇娃——
　　黄金的商品与货币属性
　　毫无疑问，褪下光环的黄金更多的时候扮演着普通贵金属的角色，从目前的消费需求来看，饰品占的比重仍然较大(78%左右)，其次是工业用途(电子、牙科、装饰等行业，17%左右)，最后才是各国央行的储备和投资需求(5%左右)。黄金饰品除了人们的装饰需要外，中外各国历来都隐含着保值、传家等金融货币功能，且不管是盛世还是乱世，对黄金的需求都会超出一般世道。与民间对黄金的热爱和认同相比，各国官方对黄金储备的态度却大相径庭：按中国人民银行网站公布的最新9月份数据显示，央行总资产为202924.40亿元人民币，其中货币黄金为337.24亿元人民币，仅占1.6%，而两年前这个比例更低，为1.0%。同比美国为75%，德国为63%，欧洲央行为33%，日本则为2%。
　　从这些数据我们发现，老牌资本主义国家和地区比较重视黄金的官方储备，相反，新兴经济体和发展中国家则较为薄弱，包括中国、俄罗斯、巴西等国，最近几年才对此有所警觉。实际上，黄金由于它本身的贵族气质和历史缘由，至发现它的那天起就没有脱离过货币属性，只不过在不同的时期表现方式有所不同罢了。
爱恨情仇——
黄金与美元的前世今身

　　美元的强势地位并没有随着二战结束后美国国力的增长而陡然提升，从上个世经40年代到60年代末，美元与黄金的挂钩起到了稳定各国币值、促进战后经济重建的重要作用，直到尼克松政府宣布不再承诺按35美元兑换一盎司黄金。很明显，美国人经过二战和大萧条之后，经济上迎来了一个较长的上升周期，黄金已成了绑在巨人身上的一把枷锁，必须予以解除，自由资本主义浪潮席重新席卷了整个西方。在接下来的美苏两大集团冷战对峙中，美国最终赢得了超强地位的同时，也把美元带上了一个新的高峰，而在这近30年的峥嵘岁月里，黄金与美元反复争夺着人们心中的那个高地——避险。1971年8月和1973年2月，美国政府两次宣布美元贬值，致使金价一路攀升，在1980年达到了当时看来不可思议的800美元/盎司，至此黄金与美元的负相关关系完全确立。
　　一个国家的币值高低，本来应该是该国经济实力的量化体现，为什么次贷危机愈演愈烈之际，美元指数还在不停地上升呢？次贷危机是从2006年春季开始逐步显现，并于2007年2月13日美国新世纪金融公司(New Century Finance)发出2006年第四季度盈利预警为标志事件而开始，至2008年7月中旬美元指数一路走低到接近70的水平，黄金在2008年3月涨过1000美元，都属于正常的教科书案例。但当布什政府和美联储宣布将动用财政资金拯救金融系统之后，投资者的态度发生了明显变化：人们意识到这场危机的空前和广度，几乎没有什么国家能够逃脱，美国的经济虽然遭受了重创，但还没有糟到不可收拾的地步，它的制度优势和军事实力依然存在，相比较而言，美元是更为稳妥的避险工具。看似不可思议的事情发生了，倒闭的金融巨头一个接一个，财政资金又源源不断地注入这些企业，一场“社会主义”改造轰轰烈烈地进行着，黄金避险的吸引力因此骤然降低。我们从最近两个月召开的北京峰会、G20峰会和OPEC峰会各国领导人的表态来看，美国虽然变得有所谦卑，但它的影响力仍然无处不在，美元的地位不会在短时期内大厦将倾。
数字时代——
　　不确定世界的温度计
　　强势美元是在什么时间段内开始事实上瓦解的？正是小布什第一任总统期间的最初两年，其间的2001年发生了改变历史进程的911世贸双子塔被撞事件，接着的阿富汗和伊拉克两场战争，不仅让美国的赤字财政达到了空前，也让美国的软实力大打折扣，美元开始了长达8年的下跌。此消彼长，中国、印度等新兴经济体快速增长，由于人口基数庞大，巨大的消费潜力随着美元贬值而释放出来，几乎所有商品都创下了历史最高价。2008年，无论政治、金融、体育还是灾难都无法让人忘怀，而奥巴马在这一历史时刻被放到了世界的聚光灯下。随着明年美国新政府的履新，有可能会加快战争的结束，同时奥巴马承诺会继续布什政府的救市措施，短期来看美国的赤字情况不会有大规模改变——包括中国、沙特在内的有经济实力国家仍在增持美国国债。美元在最近一段时间的短暂强力输血后如果仍不见起色的话，巨大的债务和极低利率导致的流动性泛滥就会卷土重来，以我们正在经历的危机为参照——它不正是拜格林斯藩的低利率政策所赐？除非奥巴马的新经济智囊团队能同时摆平赤字、就业与通胀，否则，美元会在停止输血后重回跌势，而黄金，在未来一年内重上1000美元/盎司也许并非神话。
　　从伦敦金周线分析(见附图)，今年3月和8月形成的双顶仍然有效，而846美元的颈线关键价位曾经被回撤击穿，那么最近几周的行情尤其令人关注，如果此价位再次被向上突破，这个头部能否成立就值得打问号了。
　　黄金，无论是通胀还是通缩，它都是大众心目中的诺亚方舟。
&#8211;海通期货 李潼军
]]></description>
			<content:encoded><![CDATA[<p>　　当阿里巴巴和基督山伯爵在山洞里发现金币时，那是真正的硬通货时代，也在我们童年的记忆里刻下了财富的代名词——黄金。围绕黄金的故事与传说自古就不绝于耳，但自从1973年布雷顿森林体系解体、黄金与美元的固定比价关系不复存在以来，黄金如同高贵的公主沦落民间，虽容颜依旧，却不再富贵照人。而围绕黄金由市场定价机制形成，带给全球金融体系的浮动汇率变革才算真正开始。
<p>　　一个有趣的现象是，几十年的市场选择淘汰，若论黄金交易市场的便捷与时区完备，全球其他商品与货币可能还没有出其右者。从伦敦格林威治时间每天早晨8点(北京时间下午4点)开始，然后向纽约、悉尼、东京、香港、上海、迪拜、苏黎世再回到伦敦，一天24小时，各大黄金交易场所能提供不间断的交易机会，存在即合理，为什么人们对黄金交易有如此大的“排场”需求？
<p><strong>双面娇娃——</strong>
<p><strong>　　黄金的商品与货币属性</strong>
<p>　　毫无疑问，褪下光环的黄金更多的时候扮演着普通贵金属的角色，从目前的消费需求来看，饰品占的比重仍然较大(78%左右)，其次是工业用途(电子、牙科、装饰等行业，17%左右)，最后才是各国央行的储备和投资需求(5%左右)。黄金饰品除了人们的装饰需要外，中外各国历来都隐含着保值、传家等金融货币功能，且不管是盛世还是乱世，对黄金的需求都会超出一般世道。与民间对黄金的热爱和认同相比，各国官方对黄金储备的态度却大相径庭：按中国人民银行网站公布的最新9月份数据显示，央行总资产为202924.40亿元人民币，其中货币黄金为337.24亿元人民币，仅占1.6%，而两年前这个比例更低，为1.0%。同比美国为75%，德国为63%，欧洲央行为33%，日本则为2%。
<p>　　从这些数据我们发现，老牌资本主义国家和地区比较重视黄金的官方储备，相反，新兴经济体和发展中国家则较为薄弱，包括中国、俄罗斯、巴西等国，最近几年才对此有所警觉。实际上，黄金由于它本身的贵族气质和历史缘由，至发现它的那天起就没有脱离过货币属性，只不过在不同的时期表现方式有所不同罢了。
<p><strong>爱恨情仇——</strong>
<p><strong>黄金与美元的前世今身</strong></p>
<p><span id="more-284"></span></p>
<p>　　美元的强势地位并没有随着二战结束后美国国力的增长而陡然提升，从上个世经40年代到60年代末，美元与黄金的挂钩起到了稳定各国币值、促进战后经济重建的重要作用，直到尼克松政府宣布不再承诺按35美元兑换一盎司黄金。很明显，美国人经过二战和大萧条之后，经济上迎来了一个较长的上升周期，黄金已成了绑在巨人身上的一把枷锁，必须予以解除，自由资本主义浪潮席重新席卷了整个西方。在接下来的美苏两大集团冷战对峙中，美国最终赢得了超强地位的同时，也把美元带上了一个新的高峰，而在这近30年的峥嵘岁月里，黄金与美元反复争夺着人们心中的那个高地——避险。1971年8月和1973年2月，美国政府两次宣布美元贬值，致使金价一路攀升，在1980年达到了当时看来不可思议的800美元/盎司，至此黄金与美元的负相关关系完全确立。
<p>　　一个国家的币值高低，本来应该是该国经济实力的量化体现，为什么次贷危机愈演愈烈之际，美元指数还在不停地上升呢？次贷危机是从2006年春季开始逐步显现，并于2007年2月13日美国新世纪金融公司(New Century Finance)发出2006年第四季度盈利预警为标志事件而开始，至2008年7月中旬美元指数一路走低到接近70的水平，黄金在2008年3月涨过1000美元，都属于正常的教科书案例。但当布什政府和美联储宣布将动用财政资金拯救金融系统之后，投资者的态度发生了明显变化：人们意识到这场危机的空前和广度，几乎没有什么国家能够逃脱，美国的经济虽然遭受了重创，但还没有糟到不可收拾的地步，它的制度优势和军事实力依然存在，相比较而言，美元是更为稳妥的避险工具。看似不可思议的事情发生了，倒闭的金融巨头一个接一个，财政资金又源源不断地注入这些企业，一场“社会主义”改造轰轰烈烈地进行着，黄金避险的吸引力因此骤然降低。我们从最近两个月召开的北京峰会、G20峰会和OPEC峰会各国领导人的表态来看，美国虽然变得有所谦卑，但它的影响力仍然无处不在，美元的地位不会在短时期内大厦将倾。
<p><strong>数字时代——</strong>
<p><strong>　　不确定世界的温度计</strong>
<p>　　强势美元是在什么时间段内开始事实上瓦解的？正是小布什第一任总统期间的最初两年，其间的2001年发生了改变历史进程的911世贸双子塔被撞事件，接着的阿富汗和伊拉克两场战争，不仅让美国的赤字财政达到了空前，也让美国的软实力大打折扣，美元开始了长达8年的下跌。此消彼长，中国、印度等新兴经济体快速增长，由于人口基数庞大，巨大的消费潜力随着美元贬值而释放出来，几乎所有商品都创下了历史最高价。2008年，无论政治、金融、体育还是灾难都无法让人忘怀，而奥巴马在这一历史时刻被放到了世界的聚光灯下。随着明年美国新政府的履新，有可能会加快战争的结束，同时奥巴马承诺会继续布什政府的救市措施，短期来看美国的赤字情况不会有大规模改变——包括中国、沙特在内的有经济实力国家仍在增持美国国债。美元在最近一段时间的短暂强力输血后如果仍不见起色的话，巨大的债务和极低利率导致的流动性泛滥就会卷土重来，以我们正在经历的危机为参照——它不正是拜格林斯藩的低利率政策所赐？除非奥巴马的新经济智囊团队能同时摆平赤字、就业与通胀，否则，美元会在停止输血后重回跌势，而黄金，在未来一年内重上1000美元/盎司也许并非神话。
<p>　　从伦敦金周线分析(见附图)，今年3月和8月形成的双顶仍然有效，而846美元的颈线关键价位曾经被回撤击穿，那么最近几周的行情尤其令人关注，如果此价位再次被向上突破，这个头部能否成立就值得打问号了。
<p>　　黄金，无论是通胀还是通缩，它都是大众心目中的诺亚方舟。
<p>&#8211;海通期货 李潼军</p>

<p><a href="http://feedads.g.doubleclick.net/~a/pvX7KwNvN7COqyUflNR2_v5iQ6A/0/da"><img src="http://feedads.g.doubleclick.net/~a/pvX7KwNvN7COqyUflNR2_v5iQ6A/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/pvX7KwNvN7COqyUflNR2_v5iQ6A/1/da"><img src="http://feedads.g.doubleclick.net/~a/pvX7KwNvN7COqyUflNR2_v5iQ6A/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=c7lN6JRNbZ0:2yaFAGibxB0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=c7lN6JRNbZ0:2yaFAGibxB0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=c7lN6JRNbZ0:2yaFAGibxB0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=c7lN6JRNbZ0:2yaFAGibxB0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=c7lN6JRNbZ0:2yaFAGibxB0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=c7lN6JRNbZ0:2yaFAGibxB0:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/c7lN6JRNbZ0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/12/01/%e5%bc%b1%e5%8a%bf%e7%be%8e%e5%85%83%e9%87%8d%e7%8e%b0%e6%97%a5-%e9%bb%84%e9%87%91%e6%9c%ac%e8%89%b2%e5%86%8d%e7%81%bf%e6%97%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/12/01/%e5%bc%b1%e5%8a%bf%e7%be%8e%e5%85%83%e9%87%8d%e7%8e%b0%e6%97%a5-%e9%bb%84%e9%87%91%e6%9c%ac%e8%89%b2%e5%86%8d%e7%81%bf%e6%97%b6/</feedburner:origLink></item>
		<item>
		<title>web宽度960px的秘密</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/8ZyGTUbJ9-o/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/29/%e7%bd%91%e9%a1%b5%e5%ae%bd%e5%ba%a6960px%e7%9a%84%e7%a7%98%e5%af%86/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 16:34:55 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[网站技术]]></category>
		<category><![CDATA[布局]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/29/%e7%bd%91%e9%a1%b5%e5%ae%bd%e5%ba%a6960px%e7%9a%84%e7%a7%98%e5%af%86/</guid>
		<description><![CDATA[by 玉伯
研究网页栅格系统前，来看一组数据：网站  首页页面宽度 px
Yahoo!950;淘宝950;MySpace960;新浪950;网易960;Live Search958;搜狐950;优酷960;AOL960
上面列举的都是Alexa全球排名前100的站点，它们的首页宽度为950px/960px. 除了微软的Live Search, 这些站点有个共同特点：页面结构较复杂，都可以认为是门户型网站。
再来看看Google, YouTube, Facebook, Flickr!, eBay等知名站点，它们的首页宽度没什么固定规律，共同的特点是：功能专一，页面结构相对简单。
根据上面的简单分析可以认为：当搭建页面结构复杂的门户型网站时，开发工程师们不约而同地都选择将页面宽度定为950px/960px.
这是一件很有趣的事情，为什么要选择这个宽度呢？这个宽度值究竟有什么魔力？
设计师们对苹果情有独衷。在 1024 x 768 的分辨率下，打开Firefox：

自然状态下，Firefox窗体的大小约为 974 x 650. 减掉左右两边7px的边框，网页的实际大小为上图中的红色部分，高宽为 960 x 650.
有趣的960就这样出现了。是的，可以认为一切就这么简单。栅格系统最早出现在平面设计领域，设计师们爱用苹果，苹果下浏览器的默认宽度为960px, 于是960就这么“自然”地出现了。
数字背后的奥妙
上面的“自然”出现，细究自然是不让人信服的。苹果系统的设计者们在没有喝醉酒的情况下选择了960，而不是其它什么1000之类的整数，自然另有奥妙。
科学界有很多问题都可以归结到数学问题上，我们也从数学着手：

960可以分解为2的6次方乘以3和5, 这使得960可以分割成以下宽度的整数倍：
2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 32, 40,
48, 60, 64, 80, 96, 120, 160, 192, 240, 320, 480
共26种（26 = 7 * 2 * 2 [...]]]></description>
			<content:encoded><![CDATA[<p><em>by 玉伯</em></p>
<p>研究网页栅格系统前，来看一组数据：网站  首页页面宽度 px</p>
<p><a href="http://yahoo.com/">Yahoo!</a>950;<a href="http://taobao.com/">淘宝</a>950;<a href="http://myspace.com/">MySpace</a>960;<a href="http://sina.com.cn/">新浪</a>950;<a href="http://www.163.com/">网易</a>960;<a href="http://live.com/">Live Search</a>958;<a href="http://sohu.com/">搜狐</a>950;<a href="http://youku.com/">优酷</a>960;<a href="http://aol.com/">AOL</a>960</p>
<p>上面列举的都是<a href="http://www.alexa.com/site/ds/top_sites?ts_mode=global&amp;lang=none">Alexa全球排名前100的站点</a>，它们的首页宽度为950px/960px. 除了微软的<a href="http://live.com/">Live Search</a>, 这些站点有个共同特点：页面结构较复杂，都可以认为是门户型网站。</p>
<p>再来看看<a href="http://google.com/">Google</a>, <a href="http://youtube.com/">YouTube</a>, <a href="http://facebook.com/">Facebook</a>, <a href="http://flickr.com/">Flickr!</a>, <a href="http://ebay.com/">eBay</a>等知名站点，它们的首页宽度没什么固定规律，共同的特点是：功能专一，页面结构相对简单。</p>
<p>根据上面的简单分析可以认为：当搭建页面结构复杂的门户型网站时，开发工程师们不约而同地都选择将页面宽度定为950px/960px.</p>
<p>这是一件很有趣的事情，为什么要选择这个宽度呢？这个宽度值究竟有什么魔力？</p>
<h6>设计师们对苹果情有独衷。在 1024 x 768 的分辨率下，打开Firefox：<br />
<a href="http://lifesinger.org/blog/wp-content/uploads/2008/10/grid_system_apple.png"><img title="grid_system_apple" src="http://lifesinger.org/blog/wp-content/uploads/2008/10/grid_system_apple.png" alt="" width="496" height="373" /></a><br />
自然状态下，Firefox窗体的大小约为 974 x 650. 减掉左右两边7px的边框，网页的实际大小为上图中的红色部分，高宽为 960 x 650.</h6>
<p>有趣的960就这样出现了。是的，可以认为一切就这么简单。栅格系统最早出现在平面设计领域，设计师们爱用苹果，苹果下浏览器的默认宽度为960px, 于是960就这么“自然”地出现了。<span id="more-283"></span></p>
<h4>数字背后的奥妙</h4>
<p>上面的“自然”出现，细究自然是不让人信服的。苹果系统的设计者们在没有喝醉酒的情况下选择了960，而不是其它什么1000之类的整数，自然另有奥妙。</p>
<p>科学界有很多问题都可以归结到数学问题上，我们也从数学着手：<br />
<a href="http://lifesinger.org/blog/wp-content/uploads/2008/10/960_formula.png"><img title="960_formula" src="http://lifesinger.org/blog/wp-content/uploads/2008/10/960_formula.png" alt="" width="250" height="55" /></a><br />
960可以分解为2的6次方乘以3和5, 这使得960可以分割成以下宽度的整数倍：</p>
<pre>2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 32, 40,
48, 60, 64, 80, 96, 120, 160, 192, 240, 320, 480</pre>
<p>共26种（26 = 7 * 2 * 2 &#8211; 2, 减去2是去掉1和960自身），我们标记为：</p>
<pre>N(960) = N(2^6 * 3 * 5) = 26</pre>
<p>根据上面的算法，可以得到：</p>
<pre>N(360) = N(2^3 * 3^2 * 5) = 22
N(480) = N(2^5 * 3 * 5) = 22
N(720) = N(2^4 * 3^2 * 5) = 28
N(750) = N(2 * 3 * 5^3) = 14
N(800) = N(2^5 * 5^2) = 16
N(960) = N(2^6 * 3 * 5) = 26
N(1000) = N(2^3 * 5^3) = 14
N(1024) = N(2^10) = 9
N(1440) = N(2^6 * 3^2 * 5) = 34
N(1920) = N(2^7 * 3 * 5) = 30</pre>
<p>根据直觉（严格证明也不难，不过还是留给数学系的学生去证明吧），我们得到一个有趣的结论：</p>
<p>要使得N(width)最大，width的取值有两个系列：<br />
A系列： …, 320, 720, 1440, …<br />
B系列： …, 480, 960, 1920, …</p>
<p>N越大，可组合的宽度值就越多。<strong>对栅格系统来说，这意味着越灵活！</strong></p>
<p>目前绝大多数显示器都支持 1024 x 768 及其以上分辨率。为了有效的利用屏幕宽度同时保证栅格的灵活度，可以看出960是非常合适的。这样，在目前主流显示器下，960就成为网页栅格系统中的最佳宽度了。（也许不久的将来，将会流行1440）</p>

<p><a href="http://feedads.g.doubleclick.net/~a/xERt5kq77VTraOHvkO-8FAkZSxw/0/da"><img src="http://feedads.g.doubleclick.net/~a/xERt5kq77VTraOHvkO-8FAkZSxw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/xERt5kq77VTraOHvkO-8FAkZSxw/1/da"><img src="http://feedads.g.doubleclick.net/~a/xERt5kq77VTraOHvkO-8FAkZSxw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8ZyGTUbJ9-o:8mr840-RxjI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8ZyGTUbJ9-o:8mr840-RxjI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=8ZyGTUbJ9-o:8mr840-RxjI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8ZyGTUbJ9-o:8mr840-RxjI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8ZyGTUbJ9-o:8mr840-RxjI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8ZyGTUbJ9-o:8mr840-RxjI:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/8ZyGTUbJ9-o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/29/%e7%bd%91%e9%a1%b5%e5%ae%bd%e5%ba%a6960px%e7%9a%84%e7%a7%98%e5%af%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/29/%e7%bd%91%e9%a1%b5%e5%ae%bd%e5%ba%a6960px%e7%9a%84%e7%a7%98%e5%af%86/</feedburner:origLink></item>
		<item>
		<title>QAD MFG/PRO Learning Path</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/3kCS3BOOCYs/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/27/qad-mfgpro-learning-path/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 02:47:10 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/27/qad-mfgpro-learning-path/</guid>
		<description><![CDATA[老硬盘收藏，学习QAD的路径图。

]]></description>
			<content:encoded><![CDATA[<p>老硬盘收藏，学习QAD的路径图。<br />
<a href="http://www.ericbess.com/ericblog/wp-content/uploads/2008/11/eb2-learning-path.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/11/eb2-learning-path-thumb.jpg" border="0" alt="eB2 Learning Path" width="550" height="413" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/0Qo6MkyzYFWeG_MZ17JLDOJ-A8c/0/da"><img src="http://feedads.g.doubleclick.net/~a/0Qo6MkyzYFWeG_MZ17JLDOJ-A8c/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/0Qo6MkyzYFWeG_MZ17JLDOJ-A8c/1/da"><img src="http://feedads.g.doubleclick.net/~a/0Qo6MkyzYFWeG_MZ17JLDOJ-A8c/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3kCS3BOOCYs:vHtL0mQ8GJo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3kCS3BOOCYs:vHtL0mQ8GJo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=3kCS3BOOCYs:vHtL0mQ8GJo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3kCS3BOOCYs:vHtL0mQ8GJo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3kCS3BOOCYs:vHtL0mQ8GJo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3kCS3BOOCYs:vHtL0mQ8GJo:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/3kCS3BOOCYs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/27/qad-mfgpro-learning-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/27/qad-mfgpro-learning-path/</feedburner:origLink></item>
		<item>
		<title>实用网页设计工具与资源</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/GbkUpySAwnE/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/26/web_design_tools/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 13:40:51 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[网站技术]]></category>
		<category><![CDATA[WebDesign]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/26/%e5%ae%9e%e7%94%a8%e7%bd%91%e9%a1%b5%e8%ae%be%e8%ae%a1%e5%b7%a5%e5%85%b7%e4%b8%8e%e8%b5%84%e6%ba%90/</guid>
		<description><![CDATA[网站整体css结构生成工具
CSS Layout Generator能够在您设定参数的情况下, 生成浮动宽度或者固定宽度的流体布局, 可以有三栏式的, 也可以具有头部[Header]或脚部[Footer], 各栏的宽度可以以多种尺度来衡量, 例如像素[px],等宽字体宽度[em],百分比[%]等. 此外,你你还可以选择生成文档的Doctype属性, 是HTML或者XHTML。
CSS禅意花园
CSS Zen Garden 这是一个开放的CSS社区，旨在分享设计师如果利用CSS做出令人叹服的效果。使用相同的HTML文件，设计师提交的外部样式来美化这个文件。用Web Developer Tool就可以检查CSS是如何进行布局工作的。
色彩采集工具
ColorSchemer ColorPix，一款小巧的Color Picker, 能够随着您鼠标的移动迅速的抓取屏幕颜色, 并将其转换为不同格式的颜色标识, 其优点是无需安装, 只需下载直接运行, 使用时, 可以设定不同的缩放程度, 一边夺取等精确的颜色信息, 合适的时候, 单击就可以把当前颜色代码复制到剪贴板, 此外, 改程序可以被设定为&#8221;置顶&#8221;,位于所有程序的窗口的上方。
CSS属性查看器
CSSViewer a Firefox plugin,一款小巧的CSS属性查看器,随着鼠标的移动显示当前所指示元素的CSS样式信息,其中包括了所有从父级元素继承而来,用户自定义以及浏览器自定义的样式信息. 你也可以通过在工具栏添加该扩展的图标按钮来激活/禁用该扩展。
to be continued
]]></description>
			<content:encoded><![CDATA[<h4>网站整体css结构生成工具</h4>
<p><a href="http://csscreator.com/?q=tools/layout" target="_blank">CSS Layout Generator</a>能够在您设定参数的情况下, 生成浮动宽度或者固定宽度的流体布局, 可以有三栏式的, 也可以具有头部[Header]或脚部[Footer], 各栏的宽度可以以多种尺度来衡量, 例如像素[px],等宽字体宽度[em],百分比[%]等. 此外,你你还可以选择生成文档的Doctype属性, 是HTML或者XHTML。<br />
<h4>CSS禅意花园</h4>
<p><a href="http://www.csszengarden.com/?cssfile=/208/208.css&amp;page=0"><u>CSS Zen Garden</u></a> 这是一个开放的CSS社区，旨在分享设计师如果利用CSS做出令人叹服的效果。使用相同的HTML文件，设计师提交的外部样式来美化这个文件。用<a href="http://chrispederick.com/work/web-developer/">Web Developer Tool</a>就可以检查CSS是如何进行布局工作的。<br />
<h4>色彩采集工具</h4>
<p><a href="http://www.colorschemer.com/colorpix_info.php" target="_blank">ColorSchemer ColorPix</a>，一款小巧的Color Picker, 能够随着您鼠标的移动迅速的抓取屏幕颜色, 并将其转换为不同格式的颜色标识, 其优点是无需安装, 只需下载直接运行, 使用时, 可以设定不同的缩放程度, 一边夺取等精确的颜色信息, 合适的时候, 单击就可以把当前颜色代码复制到剪贴板, 此外, 改程序可以被设定为&#8221;置顶&#8221;,位于所有程序的窗口的上方。<br />
<h4>CSS属性查看器</h4>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/2104" target="_blank">CSSViewer</a> a Firefox plugin,一款小巧的CSS属性查看器,随着鼠标的移动显示当前所指示元素的CSS样式信息,其中包括了所有从父级元素继承而来,用户自定义以及浏览器自定义的样式信息. 你也可以通过在工具栏添加该扩展的图标按钮来激活/禁用该扩展。</p>
<p><em>to be continued</em></p>

<p><a href="http://feedads.g.doubleclick.net/~a/d3e0iS8Gp_4jk2Yki1FVaYEBTQo/0/da"><img src="http://feedads.g.doubleclick.net/~a/d3e0iS8Gp_4jk2Yki1FVaYEBTQo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/d3e0iS8Gp_4jk2Yki1FVaYEBTQo/1/da"><img src="http://feedads.g.doubleclick.net/~a/d3e0iS8Gp_4jk2Yki1FVaYEBTQo/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=GbkUpySAwnE:Yzilh4u-BqM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=GbkUpySAwnE:Yzilh4u-BqM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=GbkUpySAwnE:Yzilh4u-BqM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=GbkUpySAwnE:Yzilh4u-BqM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=GbkUpySAwnE:Yzilh4u-BqM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=GbkUpySAwnE:Yzilh4u-BqM:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/GbkUpySAwnE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/26/web_design_tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/26/web_design_tools/</feedburner:origLink></item>
		<item>
		<title>PHP防止错误显示</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/69V2R0MTIV8/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/17/php_error_hide/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 14:46:43 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/17/php%e9%98%b2%e6%ad%a2%e9%94%99%e8%af%af%e6%98%be%e7%a4%ba/</guid>
		<description><![CDATA[防止错误信息出现在浏览器上，可以在相应的语句前面加上@符号，比如下面的连接数据库的语句，在数据库连接失败时不在浏览器上显示错误信息： $db=@mysql_connect(&#8230;);
]]></description>
			<content:encoded><![CDATA[<p>防止错误信息出现在浏览器上，可以在相应的语句前面加上@符号，比如下面的连接数据库的语句，在数据库连接失败时不在浏览器上显示错误信息： <br />$db=@mysql_connect(&#8230;);</p>

<p><a href="http://feedads.g.doubleclick.net/~a/5Oh2BpJThIi679R4e3Ugc5dVjJg/0/da"><img src="http://feedads.g.doubleclick.net/~a/5Oh2BpJThIi679R4e3Ugc5dVjJg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/5Oh2BpJThIi679R4e3Ugc5dVjJg/1/da"><img src="http://feedads.g.doubleclick.net/~a/5Oh2BpJThIi679R4e3Ugc5dVjJg/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=69V2R0MTIV8:As6ycKaiiJw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=69V2R0MTIV8:As6ycKaiiJw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=69V2R0MTIV8:As6ycKaiiJw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=69V2R0MTIV8:As6ycKaiiJw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=69V2R0MTIV8:As6ycKaiiJw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=69V2R0MTIV8:As6ycKaiiJw:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/69V2R0MTIV8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/17/php_error_hide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/17/php_error_hide/</feedburner:origLink></item>
		<item>
		<title>给你的blog添加多币种捐赠功能（包括人民币）</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/glF-jz_bnFE/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/12/beibao/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 05:37:25 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[网站技术]]></category>
		<category><![CDATA[PayPal]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/12/%e7%bb%99%e4%bd%a0%e7%9a%84blog%e6%b7%bb%e5%8a%a0%e5%a4%9a%e5%b8%81%e7%a7%8d%e6%8d%90%e8%b5%a0%e5%8a%9f%e8%83%bd%ef%bc%88%e5%8c%85%e6%8b%ac%e4%ba%ba%e6%b0%91%e5%b8%81%ef%bc%89/</guid>
		<description><![CDATA[要让自己的blog可持续发展，就要让它能养活自己。
前一段时间，做了个WORDPRESS赞助商插件WP-DONATORS，可以支持PAYPAL多币种捐赠、广告位售卖、个人目标赞助，并实现自动汇率换算。它有个后台与PAYPAL API实时沟通，返回付款数据，然后把捐赠人赞助商指定的广告与连接放在“捐赠人云广告位”中展示出来。
接下来是支持更多的后台与币种。首先是人民币，paypal.com不支持人民币，当然想到的是“支付宝”，可是与“支付宝”沟通，他们工作人员说不提供针对个人捐赠功能。
无意间发现“贝宝”（就是paypal 中国）最近10月间，更新了他的人民币费用政策，全免。要注意“贝宝”是paypal专门针对中国人民币的业务，不能与paypal.com帐户通用（外币），所以你要专门为“贝宝”注册帐号。注册“贝宝”

正好他们用的是同一个paypal API这样很容易就加上人民币功能。使用时，只要在后台加上“贝宝”帐号就开通RMB。当捐赠人用RMB付款,款额就去“贝宝”帐号，其他币种就去paypal帐号。可以用你的信用卡开通paypal.com外币帐户支持多币种

您可以尝试在本页边栏或下方的“Sponsored Bar”进行小额捐赠，感受本插件捐赠流程！
接下来的工作与需要的支持

接下来需要支持更多的支付平台，需要大家的推荐与提供开发接口文档。
多语言支持，已做了.po包，需要完成多语种翻译。需要语言天才支持。（并说明文档）
改进界面与表现，需要css,ajax高手支持
找bug

]]></description>
			<content:encoded><![CDATA[<h4>要让自己的blog可持续发展，就要让它能养活自己。</h4>
<p>前一段时间，做了个WORDPRESS赞助商插件<a href="http://www.ericbess.com/ericblog/2008/10/21/wp-donators/" target="_blank">WP-DONATORS</a>，可以支持<a href="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG" target="_blank">PAYPAL</a>多币种捐赠、广告位售卖、个人目标赞助，并实现自动汇率换算。它有个后台与PAYPAL API实时沟通，返回付款数据，然后把捐赠人赞助商指定的广告与连接放在“捐赠人云广告位”中展示出来。</p>
<p>接下来是支持更多的后台与币种。首先是人民币，<a href="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG" target="_blank">paypal.com</a>不支持人民币，当然想到的是“支付宝”，可是与“支付宝”沟通，他们工作人员说<a href="http://www.ericbess.com/ericblog/?s=%E6%94%AF%E4%BB%98%E5%AE%9D&amp;x=21&amp;y=7" target="_blank">不提供针对个人捐赠功能</a>。</p>
<p>无意间发现“贝宝”（就是<a href="https://www.paypal.com/cn/mrb/pal=FGQNERFLGMEPN" target="_blank">paypal 中国</a>）最近10月间，更新了他的人民币费用政策，全免。要注意“贝宝”是paypal专门针对中国人民币的业务，不能与paypal.com帐户通用（外币），所以你要专门为“贝宝”注册帐号。<a href="https://www.paypal.com/cn/mrb/pal=FGQNERFLGMEPN" target="_blank"><strong>注册“贝宝”</strong></a></p>
<p><!-- Begin PayPal Logo --><a href="https://www.paypal.com/cn/mrb/pal=FGQNERFLGMEPN" target="_blank"><img src="http://images.paypal.com/zh_CN/i/bnr/paypal_mrb_banner.gif" border="0" alt="立即注册贝宝并开始接受信用卡付款。" /></a><!-- End PayPal Logo --></p>
<p>正好他们用的是同一个paypal API这样很容易就加上人民币功能。使用时，只要在后台加上“贝宝”帐号就开通RMB。当捐赠人用RMB付款,款额就去“贝宝”帐号，其他币种就去paypal帐号。可以用你的信用卡<a href="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG" target="_blank"><strong>开通paypal.com外币帐户支持多币种</strong></a><br />
<a href="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG" target="_blank"><img src="http://images.paypal.com/en_US/i/bnr/paypal_mrb_banner.gif" border="0" alt="Sign up for PayPal and start accepting credit card payments instantly." /></a></p>
<p><em><strong><span style="color: #ff0000;">您可以尝试在本页边栏或下方的“Sponsored Bar”进行小额捐赠，感受本插件捐赠流程！</span></strong></em></p>
<h4>接下来的工作与需要的支持</h4>
<ul>
<li>接下来需要支持更多的支付平台，需要大家的推荐与提供开发接口文档。</li>
<li>多语言支持，已做了.po包，需要完成多语种翻译。需要语言天才支持。（并说明文档）</li>
<li>改进界面与表现，需要css,ajax高手支持</li>
<li>找bug</li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/4Bhct2T4Krpnk-J-K1S--xPsaHA/0/da"><img src="http://feedads.g.doubleclick.net/~a/4Bhct2T4Krpnk-J-K1S--xPsaHA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/4Bhct2T4Krpnk-J-K1S--xPsaHA/1/da"><img src="http://feedads.g.doubleclick.net/~a/4Bhct2T4Krpnk-J-K1S--xPsaHA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=glF-jz_bnFE:RI5Xy8Q1vyA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=glF-jz_bnFE:RI5Xy8Q1vyA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=glF-jz_bnFE:RI5Xy8Q1vyA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=glF-jz_bnFE:RI5Xy8Q1vyA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=glF-jz_bnFE:RI5Xy8Q1vyA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=glF-jz_bnFE:RI5Xy8Q1vyA:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/glF-jz_bnFE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/12/beibao/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/12/beibao/</feedburner:origLink></item>
		<item>
		<title>JavaScript 调用SOAP</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/NKPt2GIfh4o/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/10/javascript-soapclient/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 16:26:08 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[网站技术]]></category>
		<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/10/javascript-%e8%b0%83%e7%94%a8soap/</guid>
		<description><![CDATA[一直想直接用JavaScrip调用Xurrency.com 的 SOAP，实现汇率的AJAX，找到个JavaScript SOAP Client做了测试。本机上IE,Chrome成功返回，firefox与在host上报错，&#8221;access to restricted URI DENIED&#8221;不知其所以然。
决定放弃。改用php soapclient+jquery ajax实现。
JavaScript SOAP Client测试代码如下：

?Download test.html1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Strict//EN&#34; 
   &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34; lang=&#34;en&#34; xml:lang=&#34;en&#34;&#62;
&#60;head&#62;
&#60;title&#62;XHTML-document&#60;/title&#62;
&#60;script type=&#34;text/javascript&#34; src=&#34;soapclient.js&#34;&#62;&#60;/script&#62;
&#60;script type=&#34;text/javascript&#34;&#62;
&#160;
	function currency &#40;&#41;&#123;
		var url = &#34;http://xurrency.com/servidor_soap.php&#34;;
		var pl = new SOAPClientParameters&#40;&#41;;
		pl.add&#40;&#34;amount&#34;, 5&#41;;
		pl.add&#40;&#34;base&#34;, &#34;usd&#34;&#41;;
		pl.add&#40;&#34;target&#34;, &#34;eur&#34;&#41;;
		SOAPClient.invoke&#40;url, &#34;getValue&#34;, pl, true, Currency_callBack&#41;;
	&#125;
&#160;
	function Currency_callBack&#40;r&#41;&#123;
		 alert&#40;r&#41;;
		&#125;
&#160;
&#60;/script&#62;
&#60;/head&#62;
&#60;body&#62;
	&#60;form action=&#34;&#34;&#62;
&#60;input type=button value=&#34;Invoke&#34; onclick=&#34;currency();&#34; /&#62;
&#60;/form&#62;
&#60;/body&#62;

]]></description>
			<content:encoded><![CDATA[<p>一直想直接用JavaScrip调用Xurrency.com 的 SOAP，实现汇率的AJAX，找到个<a href="http://www.guru4.net/articoli/javascript-soap-client/en/">JavaScript SOAP Client</a>做了测试。本机上IE,Chrome成功返回，firefox与在host上报错，&#8221;access to restricted URI DENIED&#8221;不知其所以然。</p>
<p>决定放弃。改用php soapclient+jquery ajax实现。</p>
<p><a href="http://www.guru4.net/articoli/javascript-soap-client/en/">JavaScript SOAP Client</a>测试代码如下：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.ericbess.com/ericblog/wp-content/plugins/wp-codebox/wp-codebox.php?p=274&amp;download=test.html">test.html</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2744"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code" id="p274code4"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #003366; font-weight: bold;">PUBLIC</span> <span style="color: #3366CC;">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> 
   <span style="color: #3366CC;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html xmlns<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://www.w3.org/1999/xhtml&quot;</span> lang<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;en&quot;</span> xml<span style="color: #339933;">:</span>lang<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;en&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>XHTML<span style="color: #339933;">-</span>document<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;soapclient.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> currency <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://xurrency.com/servidor_soap.php&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> pl <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> SOAPClientParameters<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pl.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;amount&quot;</span><span style="color: #339933;">,</span> 5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pl.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;base&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;usd&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pl.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;target&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;eur&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		SOAPClient.<span style="color: #660066;">invoke</span><span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;getValue&quot;</span><span style="color: #339933;">,</span> pl<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> Currency_callBack<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> Currency_callBack<span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>form action<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span>button value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Invoke&quot;</span> onclick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;currency();&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/mCQqUOwmaVD9QgVcUszXr7bihoU/0/da"><img src="http://feedads.g.doubleclick.net/~a/mCQqUOwmaVD9QgVcUszXr7bihoU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/mCQqUOwmaVD9QgVcUszXr7bihoU/1/da"><img src="http://feedads.g.doubleclick.net/~a/mCQqUOwmaVD9QgVcUszXr7bihoU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NKPt2GIfh4o:_v0chvSMVYw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NKPt2GIfh4o:_v0chvSMVYw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=NKPt2GIfh4o:_v0chvSMVYw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NKPt2GIfh4o:_v0chvSMVYw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NKPt2GIfh4o:_v0chvSMVYw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NKPt2GIfh4o:_v0chvSMVYw:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/NKPt2GIfh4o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/10/javascript-soapclient/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/10/javascript-soapclient/</feedburner:origLink></item>
		<item>
		<title>PayPal 对多币种支持及使用 IPN</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/jMoBzDWIgjA/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/07/paypal/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 14:00:20 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[网站技术]]></category>
		<category><![CDATA[财金与投资]]></category>
		<category><![CDATA[PayPal]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/07/paypal-%e5%af%b9%e5%a4%9a%e5%b8%81%e7%a7%8d%e6%94%af%e6%8c%81%e5%8f%8a%e4%bd%bf%e7%94%a8-ipn/</guid>
		<description><![CDATA[Paypal支持接收以下币种
Code Currency
AUD Australian Dollar
CAD Canadian Dollar
CHF Swiss Franc
CZK Czech Koruna
DKK Danish Krone
EUR Euro
GBP Pound Sterling
HKD Hong Kong Dollar
HUF Hungarian Forint
JPY Japanese Yen
NOK Norwegian Krone
NZD New Zealand Dollar
PLN Polish Zloty
SEK Swedish Krona
SGD Singapore Dollar
USD U.S. Dolla
多币种使用 IPN
payment_gross 和 payment_fee：对于非美元付款，这些值是空缺的，所以 IPN 脚本将不把这些金额作为美元处理。
多币种变量：对于非美元付款，IPN 将添加下列多币种变量，mc_gross 和 mc_fee
mc_gross：扣除交易费之前的所收到付款实付币种的全部金额。
mc_fee：与付款相关的实付币种交易费。类似 payment_fee 变量的变量函数（在款项待付等情况下，变量不显示）。
对于租用 IPN，如注册、取消、修改、失败和 EOT， mc_currency 是租费货币，而
非付款货币。

示例 1
如果拥有美元余额的用户收到一笔 $100 USD 的付款，则下列变量将用于付款：
mc_gross = payment_gross
mc_fee [...]]]></description>
			<content:encoded><![CDATA[<h4>Paypal支持接收以下币种</h4>
<p>Code Currency<br />
AUD Australian Dollar<br />
CAD Canadian Dollar<br />
CHF Swiss Franc<br />
CZK Czech Koruna<br />
DKK Danish Krone<br />
EUR Euro<br />
GBP Pound Sterling<br />
HKD Hong Kong Dollar<br />
HUF Hungarian Forint<br />
JPY Japanese Yen<br />
NOK Norwegian Krone<br />
NZD New Zealand Dollar<br />
PLN Polish Zloty<br />
SEK Swedish Krona<br />
SGD Singapore Dollar<br />
USD U.S. Dollar</p>
<h4>多币种使用 IPN</h4>
<p><strong>payment_gross 和 payment_fee：</strong>对于非美元付款，这些值是空缺的，所以 IPN 脚本将不把这些金额作为美元处理。</p>
<p><strong>多币种变量：</strong>对于非美元付款，IPN 将添加下列多币种变量，<strong>mc_gross 和 mc_fee<br />
</strong>mc_gross：扣除交易费之前的所收到付款实付币种的全部金额。<br />
mc_fee：与付款相关的实付币种交易费。类似 payment_fee 变量的变量函数（在款项待付等情况下，变量不显示）。<br />
<em>对于租用 IPN，如注册、取消、修改、失败和 EOT， mc_currency 是租费货币，而<br />
非付款货币。</em></p>
<p><span id="more-273"></span></p>
<h4>示例 1</h4>
<p>如果拥有美元余额的用户收到一笔 $100 USD 的付款，则下列变量将用于付款：<br />
<strong>mc_gross = payment_gross<br />
mc_fee = payment_fee</strong><br />
示例3.1 多币种 IPN：美元付款<br />
payment_status = Completed<br />
payment_gross = 100<br />
payment_fee = 3.00<br />
mc_gross = 100<br />
mc_fee = 3.00<br />
mc_currency = USD</p>
<h4>示例 2</h4>
<p>如果拥有加元余额的用户收到一笔 $100 CAD 的付款，则下列变量将用于付款：<br />
mc_gross 和 mc_fee 有值。<br />
payment_gross 和 payment_fee 为空。<br />
示例3.2 多币种 IPN：加元付款<br />
payment_status = Completed<br />
payment_gross =<br />
payment_fee =<br />
mc_gross =100<br />
mc_fee = 3.00<br />
mc_currency = CAD</p>
<h4>示例 3</h4>
<p>如果账户设置为自动兑换付款（automatically convert payments），则这些变量将用于显示兑换。此例显示拥有美元余额的用户收到一笔 100 GBP （Pound Sterling）的付款：<br />
示例3.3 多币种 IPN：英镑付款的自动兑换 Automatic Conversion of GBP Payment<br />
payment_status = Completed<br />
payment_gross =<br />
payment_fee =<br />
mc_gross = 100<br />
mc_fee = 3.00<br />
mc_currency = GBP<br />
settle_amount = 145.5<br />
settle_currency = USD<br />
exchange_rate = 1.5</p>
<h4>示例 4</h4>
<p>如果收到的付款由于 pending_reason = multi_currency 而处于待付状态，则收到的第一<br />
个 IPN 将没有 settle_amount、settle_currency 或 exchange_rate。</p>
<p>示例3.4 多币种 IPN：待付款（Pending Payment）<br />
payment_status = Pending<br />
pending_reason = multi_currency<br />
payment_gross =<br />
mc_gross = 100<br />
mc_currency = GBP</p>
<p>第二个 IPN 包含有关结算付款的信息。如果付款以账户的主要币种（primary currency）接受，在以下示例<br />
中为美元：<br />
示例3.5 待付 — 兑换为主要币种<br />
payment_status = Completed<br />
payment_gross =<br />
payment_fee =<br />
mc_gross = 100<br />
mc_fee = 3.00<br />
mc_currency = GBP<br />
settle_amount = 145.5<br />
settle_currency = USD<br />
exchange_rate = 1.5</p>

<p><a href="http://feedads.g.doubleclick.net/~a/EKisoZboJ_RJyKTqi6-XGfhm_lk/0/da"><img src="http://feedads.g.doubleclick.net/~a/EKisoZboJ_RJyKTqi6-XGfhm_lk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/EKisoZboJ_RJyKTqi6-XGfhm_lk/1/da"><img src="http://feedads.g.doubleclick.net/~a/EKisoZboJ_RJyKTqi6-XGfhm_lk/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=jMoBzDWIgjA:v7graNajjlw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=jMoBzDWIgjA:v7graNajjlw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=jMoBzDWIgjA:v7graNajjlw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=jMoBzDWIgjA:v7graNajjlw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=jMoBzDWIgjA:v7graNajjlw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=jMoBzDWIgjA:v7graNajjlw:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/jMoBzDWIgjA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/07/paypal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/07/paypal/</feedburner:origLink></item>
		<item>
		<title>Zend Studio debug Tips</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/a8R-SPB-1P4/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/04/zend-studio-debug-tips/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 05:17:01 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/04/zend-studio-debug-tips/</guid>
		<description><![CDATA[How to Set $_GET and $_POST vars in the debugger

Click on the &#8216;variables&#8217; tab of your debug window. You will notice a lot of global, server, and environment vairables. Among them, you should see the empty $_GET and $_POST arrays.
 Right-click on either array and choose &#8216;assign value.&#8217; To input an array, type it in [...]]]></description>
			<content:encoded><![CDATA[<h4>How to Set $_GET and $_POST vars in the debugger</h4>
<ol>
<li>Click on the &#8216;variables&#8217; tab of your debug window. You will notice a lot of global, server, and environment vairables. Among them, you should see the empty $_GET and $_POST arrays.</li>
<li> Right-click on either array and choose &#8216;assign value.&#8217; To input an array, type it in this format:array(value1 =&gt; foo, value2 =&gt; bar, name =&gt; &#8216;James Cricket&#8217;)</li>
</ol>

<p><a href="http://feedads.g.doubleclick.net/~a/gu7PndK9jesKs4YyeTUlSpx4BFo/0/da"><img src="http://feedads.g.doubleclick.net/~a/gu7PndK9jesKs4YyeTUlSpx4BFo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/gu7PndK9jesKs4YyeTUlSpx4BFo/1/da"><img src="http://feedads.g.doubleclick.net/~a/gu7PndK9jesKs4YyeTUlSpx4BFo/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=a8R-SPB-1P4:zb_LP0vRt_Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=a8R-SPB-1P4:zb_LP0vRt_Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=a8R-SPB-1P4:zb_LP0vRt_Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=a8R-SPB-1P4:zb_LP0vRt_Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=a8R-SPB-1P4:zb_LP0vRt_Q:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=a8R-SPB-1P4:zb_LP0vRt_Q:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/a8R-SPB-1P4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/04/zend-studio-debug-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/04/zend-studio-debug-tips/</feedburner:origLink></item>
		<item>
		<title>ZendDebugger for Freebad</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/nRvXQpVhJJ0/</link>
		<comments>http://www.ericbess.com/ericblog/2008/11/03/zenddebugger-for-freebad/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 08:29:39 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/11/03/zenddebugger-for-freebad/</guid>
		<description><![CDATA[Requester:
disable your ZendOptimizer and eaccelerator
download ZendDebugger.os place to /usr/local/lib/php/20060613/ 
Install:
edit your php.ini. For me php.ini is in /usr/local/etc/
[Zend]
zend_extension=/usr/local/lib/php/20060613/ZendDebugger.so
zend_debugger.allow_hosts=10.10.2.0/24
zend_debugger.expose_remotely=always
zend_debugger.connector_port=10001
restart your apache
Look in the phpinfo( ) got the result below!

Reference:Installing Zend Platform 3.0.3 on FreeBSD 6.2 with Apache 1.3 and PHP 5.2.4
]]></description>
			<content:encoded><![CDATA[<h4>Requester:</h4>
<p>disable your ZendOptimizer and eaccelerator<br />
download ZendDebugger.os place to /usr/local/lib/php/20060613/  Note: There is a file embedded within this post, please visit this post to download the file.</p>
<h4>Install:</h4>
<p>edit your php.ini. For me php.ini is in /usr/local/etc/</p>
<p><code>[Zend]<br />
zend_extension=/usr/local/lib/php/20060613/ZendDebugger.so<br />
zend_debugger.allow_hosts=10.10.2.0/24<br />
zend_debugger.expose_remotely=always<br />
zend_debugger.connector_port=10001</code></p>
<p>restart your apache</p>
<p>Look in the phpinfo( ) got the result below!</p>
<p><a href="http://www.ericbess.com/ericblog/wp-content/uploads/2008/11/zenddebugger.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/11/zenddebugger-thumb.jpg" border="0" alt="zenddebugger" width="592" height="87" /></a></p>
<p>Reference:<a title="Permanent Link: Installing Zend Platform 3.0.3 on FreeBSD 6.2 with Apache 1.3 and PHP 5.2.4" rel="bookmark" href="http://www.mitrović.com/?p=11"><span style="color: #356aa0;">Installing Zend Platform 3.0.3 on FreeBSD 6.2 with Apache 1.3 and PHP 5.2.4</span></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/YSdpn3-2llI9pyBd5g0rtwD3Vu0/0/da"><img src="http://feedads.g.doubleclick.net/~a/YSdpn3-2llI9pyBd5g0rtwD3Vu0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/YSdpn3-2llI9pyBd5g0rtwD3Vu0/1/da"><img src="http://feedads.g.doubleclick.net/~a/YSdpn3-2llI9pyBd5g0rtwD3Vu0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=nRvXQpVhJJ0:TEkpGJubkZc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=nRvXQpVhJJ0:TEkpGJubkZc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=nRvXQpVhJJ0:TEkpGJubkZc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=nRvXQpVhJJ0:TEkpGJubkZc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=nRvXQpVhJJ0:TEkpGJubkZc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=nRvXQpVhJJ0:TEkpGJubkZc:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/nRvXQpVhJJ0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/11/03/zenddebugger-for-freebad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/11/03/zenddebugger-for-freebad/</feedburner:origLink></item>
		<item>
		<title>php防止恶意访问小程序</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/5kqqLqGDvyE/</link>
		<comments>http://www.ericbess.com/ericblog/2008/10/30/php_avoid_refres/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 13:50:47 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[安全]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=266</guid>
		<description><![CDATA[本来写PAYPAL IPN response 时用来防止反复尝试的函数，保护性很差，后来改成原地址审核($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);if(!preg_match(&#8217;/paypal\.com$/&#8217;, $hostname)) {&#8230;..),所以个就弃用了。在删之前记录不来，应该有更好的算法，不知道谁有研究。

?View Code PHP1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if &#40;!avoid_refresh &#40;'15'&#41;&#41; die &#40;&#34;Hacking Attempt!!&#34;&#41;;
.....
.....
.....
function avoid_refresh &#40;$time&#41;&#123;
	session_start&#40;&#41;;
  if &#40;isset&#40;$_SESSION&#91;&#34;post_sep&#34;&#93;&#41;&#41; &#123;
      if &#40;time&#40;&#41; - $_SESSION&#91;&#34;post_sep&#34;&#93; &#60; $time&#41;  &#123;
      	$_SESSION&#91;&#34;post_sep&#34;&#93; = time&#40;&#41;;
        return false;
     [...]]]></description>
			<content:encoded><![CDATA[<p>本来写PAYPAL IPN response 时用来防止反复尝试的函数，保护性很差，后来改成原地址审核($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);if(!preg_match(&#8217;/paypal\.com$/&#8217;, $hostname)) {&#8230;..),所以个就弃用了。在删之前记录不来，应该有更好的算法，不知道谁有研究。</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p266code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2666"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p266code6"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>avoid_refresh <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'15'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hacking Attempt!!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">.....</span>
<span style="color: #339933;">.....</span>
<span style="color: #339933;">.....</span>
<span style="color: #000000; font-weight: bold;">function</span> avoid_refresh <span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<a href="http://www.php.net/session_start"><span style="color: #990000;">session_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;post_sep&quot;</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;post_sep&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
      	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;post_sep&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</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: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;post_sep&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;post_sep&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #009900;">&#125;</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/eo1uVjhtWTHwqdxzMRF_eCK0LmQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/eo1uVjhtWTHwqdxzMRF_eCK0LmQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/eo1uVjhtWTHwqdxzMRF_eCK0LmQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/eo1uVjhtWTHwqdxzMRF_eCK0LmQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=5kqqLqGDvyE:qmYfjp3xFiY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=5kqqLqGDvyE:qmYfjp3xFiY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=5kqqLqGDvyE:qmYfjp3xFiY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=5kqqLqGDvyE:qmYfjp3xFiY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=5kqqLqGDvyE:qmYfjp3xFiY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=5kqqLqGDvyE:qmYfjp3xFiY:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/5kqqLqGDvyE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/10/30/php_avoid_refres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/10/30/php_avoid_refres/</feedburner:origLink></item>
		<item>
		<title>PHP 数据加密</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/8rQsI32l0zc/</link>
		<comments>http://www.ericbess.com/ericblog/2008/10/30/php-crypt/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 05:51:51 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[安全]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=265</guid>
		<description><![CDATA[��据加密在我们生活中的地位已经越来越重要了，尤其是考虑到在网络上发生的大量交易和传输的大量数据。如果对于采用安全措施有兴趣的话，也一定会有兴趣了解PHP提供的一系列安全功能。在本篇文章中，我们将介绍这些功能，提供一些基本的用法，以便你能够为自己的应用软件中增加安全功能。
预备知识
在详细介绍PHP的安全功能之前，我们需要花点时间来向没有接触过这方面内容的读者介绍一些有关密码学的基本知识，如果对密码学的基本概念已经非常熟悉，就可以跳过去这一部分。
密码学可以通俗地被描述为对加/解密的研究和实验，加密是将易懂的资料转换为不易懂资料的过程，解密则是将不易懂的资料转换为原来易懂资料的过程。不易懂的资料被称作密码，易懂的资料被称作明码。
数据的加/解密都需要一定的算法，这些算法可以非常地简单，如著名的凯撒码，但当前的加密算法要相对复杂得多，其中一些利用现有的方法甚至是无法破译的 。
PHP的加密功能只要有一点使用非Windows平台经验的人可能对crypt()也相当熟悉，这一函数完成被称作单向加密的功能，它可以加密一些明码，但不能够将密码转换为原来的明码。尽管从表面上来看这似乎是一个没有什么用处的功能，但它的确被广泛用来保证系统密码的完整性。因为，单向加密的口令一旦落入第三方人的手里，由于不能被还原为明文，因此也没有什么大用处。在验证用户输入的口令时，用户的输入采用的也是单向算法，如果输入与存储的经加密后的口令相匹配，则输入的口信一定是正确的。
crypt()函数
PHP同样提供了使用其crypt()函数完成单向加密功能的可能性。我将在这里简要地介绍该函数：
string crypt (string input_string [, string salt])
其中的input_string参数是需要加密的字符串，第二个可选的salt是一个位字串，它能够影响加密的暗码，进一步地排除被称作预计算攻击的可能性。缺省情况下，PHP使用一个2个字符的DES干扰串，如果你的系统使用的是MD5（我将在以后介绍MD5算法），它会使用一个12个字符的干扰串。顺便说一下，可以通过执行下面的命令发现系统将要使用的干扰串的长度：
print “My system salt size is: ”. CRYPT_SALT_LENGTH;
系统也可能支持其他的加密算法。crypt()支持四 种算法，下面是它支持的算法和相应的salt参数的长度：
算法 Salt长度
CRYPT_STD_DES 2-character (Default)
CRYPT_EXT_DES 9-character
CRYPT_MD5 12-character beginning with $
CRYPT_BLOWFISH 16-character beginning with $

用crypt()实现用户身份验证
作为crypt()函数的一个例子，考虑这样一种情况，你希望创建一段PHP脚本程序限制对一个目录的访问，只允许能够提供正确的用户名和口令的用户访问这一目录。我将把资料存储在我喜欢的数据库MySQL的一个表中。下面我们以创建这个被称作members的表开始我们的例子：
mysql&#62;CREATE TABLE members (
-&#62;username CHAR(14) NOT NULL,
-&#62;password CHAR(32) NOT NULL,
-&#62;PRIMARY KEY(username)
-&#62;);
然后，我们假定下面的数据已经存储在该表中：
用户名 密码
clark keloD1C377lKE
bruce ba1T7vnz9AWgk
peter paLUvRWsRLZ4U
这些加密的口令对应的明码分别是kent、banner和parker。注意一下每个口令的前二个字母，这是因为我使用了下面的代码，根据口令的前二个字母创建干扰串的：
$enteredPassword.
$salt = substr($enteredPassword, 0, 2);
$userPswd = crypt($enteredPassword, $salt);
// $userPswd然后就和用户名一起存储在MySQL 中
我将使用Apache的口令-应答认证配置提示用户输入用户名和口令，一个鲜为人知的有关PHP的信息是，它可以把Apache的口令-应答系统输入的用户名和口令识别为$PHP_AUTH_USER和$PHP_AUTH_PW，我将在身份验证脚本中用到这二个变量。花一些时间仔细阅读下面的脚本，多注意一下其中的解释，以便更好地理解下面的代码：
crypt()和Apache的口令-应答验证系统的应用

?View Code PHP1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
&#60;?php 
  [...]]]></description>
			<content:encoded><![CDATA[数据加密在我们生活中的地位已经越来越重要了，尤其是考虑到在网络上发生的大量交易和传输的大量数据。如果对于采用安全措施有兴趣的话，也一定会有兴趣了解PHP提供的一系列安全功能。在本篇文章中，我们将介绍这些功能，提供一些基本的用法，以便你能够为自己的应用软件中增加安全功能。</p>
<h4>预备知识</h4>
<p>在详细介绍PHP的安全功能之前，我们需要花点时间来向没有接触过这方面内容的读者介绍一些有关密码学的基本知识，如果对密码学的基本概念已经非常熟悉，就可以跳过去这一部分。</p>
<p>密码学可以通俗地被描述为对加/解密的研究和实验，加密是将易懂的资料转换为不易懂资料的过程，解密则是将不易懂的资料转换为原来易懂资料的过程。不易懂的资料被称作密码，易懂的资料被称作明码。</p>
<p>数据的加/解密都需要一定的算法，这些算法可以非常地简单，如著名的凯撒码，但当前的加密算法要相对复杂得多，其中一些利用现有的方法甚至是无法破译的 。</p>
<p>PHP的加密功能只要有一点使用非Windows平台经验的人可能对crypt()也相当熟悉，这一函数完成被称作单向加密的功能，它可以加密一些明码，但不能够将密码转换为原来的明码。尽管从表面上来看这似乎是一个没有什么用处的功能，但它的确被广泛用来保证系统密码的完整性。因为，单向加密的口令一旦落入第三方人的手里，由于不能被还原为明文，因此也没有什么大用处。在验证用户输入的口令时，用户的输入采用的也是单向算法，如果输入与存储的经加密后的口令相匹配，则输入的口信一定是正确的。</p>
<h4>crypt()函数</h4>
<p>PHP同样提供了使用其crypt()函数完成单向加密功能的可能性。我将在这里简要地介绍该函数：</p>
<p>string crypt (string input_string [, string salt])
<p>其中的input_string参数是需要加密的字符串，第二个可选的salt是一个位字串，它能够影响加密的暗码，进一步地排除被称作预计算攻击的可能性。缺省情况下，PHP使用一个2个字符的DES干扰串，如果你的系统使用的是MD5（我将在以后介绍MD5算法），它会使用一个12个字符的干扰串。顺便说一下，可以通过执行下面的命令发现系统将要使用的干扰串的长度：</p>
<p>print “My system salt size is: ”. CRYPT_SALT_LENGTH;</p>
<p>系统也可能支持其他的加密算法。crypt()支持四 种算法，下面是它支持的算法和相应的salt参数的长度：</p>
<p>算法 Salt长度<br />
CRYPT_STD_DES 2-character (Default)<br />
CRYPT_EXT_DES 9-character<br />
CRYPT_MD5 12-character beginning with $<br />
CRYPT_BLOWFISH 16-character beginning with $<br />
<span id="more-265"></span></p>
<h5>用crypt()实现用户身份验证</h5>
<p>作为crypt()函数的一个例子，考虑这样一种情况，你希望创建一段PHP脚本程序限制对一个目录的访问，只允许能够提供正确的用户名和口令的用户访问这一目录。我将把资料存储在我喜欢的数据库MySQL的一个表中。下面我们以创建这个被称作members的表开始我们的例子：</p>
<p>mysql&gt;CREATE TABLE members (<br />
-&gt;username CHAR(14) NOT NULL,<br />
-&gt;password CHAR(32) NOT NULL,<br />
-&gt;PRIMARY KEY(username)<br />
-&gt;);</p>
<p>然后，我们假定下面的数据已经存储在该表中：</p>
<p>用户名 密码<br />
clark keloD1C377lKE<br />
bruce ba1T7vnz9AWgk<br />
peter paLUvRWsRLZ4U</p>
<p>这些加密的口令对应的明码分别是kent、banner和parker。注意一下每个口令的前二个字母，这是因为我使用了下面的代码，根据口令的前二个字母创建干扰串的：</p>
<p>$enteredPassword.<br />
$salt = substr($enteredPassword, 0, 2);<br />
$userPswd = crypt($enteredPassword, $salt);<br />
// $userPswd然后就和用户名一起存储在MySQL 中</p>
<p>我将使用Apache的口令-应答认证配置提示用户输入用户名和口令，一个鲜为人知的有关PHP的信息是，它可以把Apache的口令-应答系统输入的用户名和口令识别为$PHP_AUTH_USER和$PHP_AUTH_PW，我将在身份验证脚本中用到这二个变量。花一些时间仔细阅读下面的脚本，多注意一下其中的解释，以便更好地理解下面的代码：</p>
<p>crypt()和Apache的口令-应答验证系统的应用</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p265code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26510"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code" id="p265code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
    <span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> “localhost”<span style="color: #339933;">;</span> 
    <span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> “zorro”<span style="color: #339933;">;</span> 
    <span style="color: #000088;">$pswd</span> <span style="color: #339933;">=</span> “hell odolly”<span style="color: #339933;">;</span> 
    <span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> “users”<span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">// Set authorization to False </span>
    <span style="color: #000088;">$authorization</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">// Verify that user has entered username and password </span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$PHP_AUTH_USER</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$PHP_AUTH_PW</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 
    <a href="http://www.php.net/mysql_pconnect"><span style="color: #990000;">mysql_pconnect</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pswd</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span>“Can’t connect to <a href="http://www.php.net/mysql"><span style="color: #990000;">MySQL</span></a> server<span style="color: #339933;">!</span>”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <a href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span>“Can’t select database<span style="color: #339933;">!</span>”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">// Perform the encryption </span>
    <span style="color: #000088;">$salt</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$PHP_AUTH_PW</span><span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> 2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #000088;">$encrypted_pswd</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/crypt"><span style="color: #990000;">crypt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$PHP_AUTH_PW</span><span style="color: #339933;">,</span> <span style="color: #000088;">$salt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">// Build the query </span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> “SELECT username FROM members WHERE 
    username <span style="color: #339933;">=</span> ’<span style="color: #000088;">$PHP_AUTH_USER</span>’ AND 
    password <span style="color: #339933;">=</span> ’<span style="color: #000088;">$encrypted_pswd</span>’”<span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">// Execute the query </span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_numrows"><span style="color: #990000;">mysql_numrows</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> 1<span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 
    <span style="color: #000088;">$authorization</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">// confirm authorization </span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$authorization</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 
&nbsp;
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span>’WWW<span style="color: #339933;">-</span>Authenticate<span style="color: #339933;">:</span> Basic realm<span style="color: #339933;">=</span>“<span style="color: #000000; font-weight: bold;">Private</span>”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span>HTTP<span style="color: #339933;">/</span>1<span style="color: #339933;">.</span>0 401 Unauthorized<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">print</span> “You are unauthorized to enter this area<span style="color: #339933;">.</span>”<span style="color: #339933;">;</span> 
    <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> 
    <span style="color: #b1b100;">print</span>“This is the secret data<span style="color: #339933;">!</span>”<span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>上面就是一个核实用户访问权限的简单身份验证系统。在使用crypt()保护重要的机密资料时，记住在缺省状态下使用的crypt()并不是最安全的，只能用在对安全性要求较低的系统中，如果需要较高的安全性能，就需要我在本篇文章的后面介绍的算法。</p>
<h4>md5()函数</h4>
<p>下面我将介绍另一个PHP支持的函数━━md5()，这一函数使用MD5散列算法，它有几种很有趣的用法值得一提：</p>
<p>混编</p>
<p>一个混编函数可以将一个可变长度的信息变换为具有固定长度被混编过的输出，也被称作“信息文摘”。这是十分有用的，因为一个固定长度的字符串可以用来检查文件的完整性和验证数字签名以及用户身份验证。由于它适合于PHP，PHP内置的md5()混编函数将把一个可变长度的信息转换为128位（32个字符）的信息文摘。混编的一个有趣的特点是不能通过分析混编后的信息得到原来的明码，因为混编后的结果与原来的明码内容没有依赖关系。 即便只改变一个字符串中的一个字符，也将使得MD5混编算法计算出二个截然不同的结果。我们首先来看下表的内容及其相应的结果：</p>
<p>使用md5()混编字符串</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p265code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26511"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p265code11"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
    <span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> “This is some message that I just wrote”<span style="color: #339933;">;</span> 
    <span style="color: #000088;">$enc_msg</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/md5"><span style="color: #990000;">md5</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">print</span> “<a href="http://www.php.net/hash"><span style="color: #990000;">hash</span></a><span style="color: #339933;">:</span> <span style="color: #000088;">$enc_msg</span> ”<span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>结果：</p>
<p>hash: 81ea092649ca32b5ba375e81d8f4972c</p>
<p>注意，结果的长度为32个字符。再来看一下下面的表，其中的$msg的值有了一点 微小的变化：</p>
<p>使用md5()对一个稍微变化的字符串进行混编</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p265code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26512"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p265code12"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
    <span style="color: #666666; font-style: italic;">//注意，message中少了一个s </span>
    <span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> “This is some mesage that I just wrote”<span style="color: #339933;">;</span> 
    <span style="color: #000088;">$enc_msg</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/md5"><span style="color: #990000;">md5</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">print</span>“hash2<span style="color: #339933;">:</span> <span style="color: #000088;">$enc_msg</span> <span style="color: #339933;">&lt;</span>br <span style="color: #339933;">/&gt;&lt;</span>br <span style="color: #339933;">/&gt;</span>”<span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>结果：</p>
<p>hash2: e86cf511bd5490d46d5cd61738c82c0c</p>
<p>可以发现，尽管二个结果的长度都是32个字符，但明文中一点微小的变化使得结果发生了很大的变化，因此，混编和md5()函数是检查数据中微小变化的一个很好的工具。</p>
<p>尽管crypt()和md5()各有用处，但二者在功能上都受到一定的限制。在下面的部分中，我们将介绍二个非常有用的被称作Mcrypt和Mhash的PHP扩展，将大大拓展PHP用户在加密方面的选择。</p>
<p>尽管我们在上面的小节中说明了单向加密的重要性，但有时我们可能需要在加密后，再把密码数据还原成原来的数据，幸运的是，PHP通过Mcrypt扩展库的形式提供了这种可能性。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/EdONrB3W-JHFHlyRbUcnZZhxkdA/0/da"><img src="http://feedads.g.doubleclick.net/~a/EdONrB3W-JHFHlyRbUcnZZhxkdA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/EdONrB3W-JHFHlyRbUcnZZhxkdA/1/da"><img src="http://feedads.g.doubleclick.net/~a/EdONrB3W-JHFHlyRbUcnZZhxkdA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8rQsI32l0zc:EggQ93K2gYs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8rQsI32l0zc:EggQ93K2gYs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=8rQsI32l0zc:EggQ93K2gYs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8rQsI32l0zc:EggQ93K2gYs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8rQsI32l0zc:EggQ93K2gYs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8rQsI32l0zc:EggQ93K2gYs:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/8rQsI32l0zc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/10/30/php-crypt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/10/30/php-crypt/</feedburner:origLink></item>
		<item>
		<title>WordPress 插件\主题 本地化</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/uc6jZSspgxU/</link>
		<comments>http://www.ericbess.com/ericblog/2008/10/27/wp_develop_i1n/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 15:52:34 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[WP Programming]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[网站技术]]></category>
		<category><![CDATA[WP-Coding]]></category>
		<category><![CDATA[国际化]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=264</guid>
		<description><![CDATA[��旦你的插件编程工作已结束，另一个值得考虑的方面就是怎样将你的插件国际化（当然，这是建立在你想把你的作品发布给公众的前提上）。“国际化”就是一个建设你的软件使之能被本地化的过程；而“本地化”就是将你软件显示文本翻译成各种语言的过程。WordPress 已被来自全世界各个地方的爱好者使用，所以它以将国际化和本地化功能融入其结构，包括插件程序的本地化功能。想了解更多的 GNU gettext 本地化的背景知识，请参照翻译 WordPress。
极力推荐你将你的插件进行国际化，这样来自五湖四海的用户名都可以本地化它。而且这整个过程也是十分直接明了：

先给你的插件选一个翻译用的“文本域”名称。这一般同你的插件文件名称相同，当然不包括.php后缀名，而且必须是具有唯一性，至少保证不要同使用者已安装的其他插件同名。
不管任何时候你的插件要使用文字来显示给网页读者（也即“信息文”），都尽量将它们嵌入在如下两个 WordPress gettext 函数程序段的任一之中。记住，不同于 WordPress 核心代码，在你插件里的国际化函数里你应该使用第二个参数来传递你自选的文本域。而在 WordPress 核心代码，这个参数默认为空。

__() 用来将 message 作为一个参数传递给另外一个函数。 _e() 用来直接把 message 写到页面上。

__($message, $domain) ： 用本地化的语言为 $domain 翻译 $message 。输出的字符串可以继续被其他函数调用。 
_e($message, $domain) ：用本地化的语言为 $domain 翻译 $message ，然后显示到用户的屏幕。如果你的文字将直接显示给读者，就可以使用该函数。 


为你的插件创建一个 POT 文件 （这个一个列有所有文字条的翻译条目文件），随你的插件一起发布。插件用户将需要生成一个翻译本地化好的 MO 文件，然后把它放在你插件的同一文件夹里。并且这个 mo 文件的取名也有讲究，应该是象 domain-ll_CC.mo，这里 ll_CC 就是本地国家和语言代码（如 zh_CN）。参照 翻译 WordPress 上更多关于 POT 文件、MO 文件及本地化的信息。
在你插件里加入一个 load_plugin_textdomain 子程序用以调用你的插件翻译。这个子程序一定需要在你 gettext [...]]]></description>
			<content:encoded><![CDATA[<p>一旦你的插件编程工作已结束，另一个值得考虑的方面就是怎样将你的插件国际化（当然，这是建立在你想把你的作品发布给公众的前提上）。“国际化”就是一个建设你的软件使之能被本地化的过程；而“本地化”就是将你软件显示文本翻译成各种语言的过程。WordPress 已被来自全世界各个地方的爱好者使用，所以它以将国际化和本地化功能融入其结构，包括插件程序的本地化功能。想了解更多的 GNU gettext 本地化的背景知识，请参照<a title="Translating WordPress" href="http://www.ericbess.com/Translating_WordPress">翻译 WordPress</a>。</p>
<p>极力推荐你将你的插件进行国际化，这样来自五湖四海的用户名都可以本地化它。而且这整个过程也是十分直接明了：</p>
<ul>
<li>先给你的插件选一个翻译用的“文本域”名称。这一般同你的插件文件名称相同，当然不包括<tt>.php</tt>后缀名，而且必须是具有唯一性，至少保证不要同使用者已安装的其他插件同名。</li>
<li>不管任何时候你的插件要使用文字来显示给网页读者（也即“信息文”），都尽量将它们嵌入在如下两个 WordPress gettext 函数程序段的任一之中。记住，不同于 WordPress 核心代码，在你插件里的国际化函数里你应该使用第二个参数来传递你自选的文本域。而在 WordPress 核心代码，这个参数默认为空。</li>
</ul>
<p><tt>__()</tt> 用来将 message 作为一个参数传递给另外一个函数。 <tt>_e()</tt> 用来直接把 message 写到页面上。</p>
<dl>
<dt><tt>__($message, $domain)</tt> ： 用本地化的语言为 <tt>$domain</tt> 翻译 <tt>$message</tt> 。输出的字符串可以继续被其他函数调用。 </dt>
<dt><tt>_e($message, $domain)</tt> ：用本地化的语言为 <tt>$domain</tt> 翻译 <tt>$message</tt> ，然后显示到用户的屏幕。如果你的文字将直接显示给读者，就可以使用该函数。 </dt>
</dl>
<ul>
<li>为你的插件创建一个 POT 文件 （这个一个列有所有文字条的翻译条目文件），随你的插件一起发布。插件用户将需要生成一个翻译本地化好的 MO 文件，然后把它放在你插件的同一文件夹里。并且这个 mo 文件的取名也有讲究，应该是象 <tt>domain-ll_CC.mo</tt>，这里 <tt>ll_CC</tt> 就是本地国家和语言代码（如 zh_CN）。参照 <a title="Translating WordPress" href="http://www.ericbess.com/Translating_WordPress">翻译 WordPress</a> 上更多关于 POT 文件、MO 文件及本地化的信息。</li>
<li>在你插件里加入一个 <tt>load_plugin_textdomain</tt> 子程序用以调用你的插件翻译。这个子程序一定需要在你 gettext 函数的前面，但最好是越晚越好（因为一些多语言插件在调用时会改变一些地域设置）。一个可行的方法就是在你所有插件的子程序前面增加一个初始子程序。例如，假设你的文本域叫 &#8220;fabfunc&#8221;，则：</li>
</ul>
<p><span id="more-264"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p264code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26416"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p264code16"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fabfunc_domain</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'fabfunc'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fabfunc_is_setup</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> fabfunc_setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$fabfunc_domain</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fabfunc_is_setup</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fabfunc_is_setup</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   load_plugin_textdomain<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fabfunc_domain</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp-content/plugins'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<pre>假如你的插件是放在它自己的目录里，则你应该把它的目录名加到 <tt>load_plugin_textdomain</tt> 函数的第二个参数里。</pre>
<h4>插件和主题模板的 mo 语言文件取名和该上传到什么地方。</h4>
<p>大家知道，如果想汉化整个 WordPress，就是下载或自己生成一个叫 zh_CN.mo 的文件然后上传到 wp-content/languages 子目录里，然后修改 wp-config.php文件就行了。但在主题和插件的本地化中略有不同。<br />
在插件中，.mo 文件的名字应该与插件国际化“文本域”名称有联系，格式是 $textdomain-ll-CC.mo。比方说，我的一个插件叫 superit，那么我的汉化文件名就应该取成 superit-zh_CN.mo。以此类推可知，$textdomain 是文本域， ll 是语言名, CC 是国家区域代号。注意：在文本域与语言、国家代码之间是小横线(-)，而在语言和国家代码之间是下划线（_)。<br />
然而主题中的 mo 文件仍可以取名为 zh_CN.mo 如果你用的函数是 load_theme_textdomain 的话。</p>
<p>同样的道理是做好的 mo 文件上传的路径也不一样。<br />
插件的还要取决于我在上面提到的那个 load_plugin_textdomain（$domain, $path）函数中的第二个参数$path。假如我在我的插件 functions.php 文件用到的是 load_plugin_textdomain (’superit’,&#8217;wp-content/plugins/superit’); 则我应该将我的 superit-zh_CN.mo 上传到我的插件子目录 wp-content/plugins/superit 里面。<br />
如果我的函数写成是 load_plugin_textdomain (’superit’,&#8217;wp-content/plugins’); 那将 .mo 文件上传到 wp-content/plugins 子目录里就行了，若不小心还是上传到 superit 插件子目录里，那这插件可能得不到汉化。所以，汉化时请注意你要用的插件里的 load_plugin_textdomain 路径参数。<br />
而主题却不一样，汉化时只要把做好的 zh_CN.mo 上传到你使用的主题的那个子目录里然后保证你在 wp-config.php 里启用中文就行 了。</p>
<h4>怎样在插件和主题里调用 gettext 的函数子程序</h4>
<p>按照 WP 官方文档的推荐，在插件和主题里应该生成独特的“文本域”来区分 WP 核心部分的本地化。<br />
实现上述需求要用 load_plugin_textdomain ($domain, $path) 函数子程序。在这里，$domain 应该是你自己原选好的独特的“文本域”，一般是你插件或主题的名字。而$path就是语言 mo 文件所在的位置。<br />
什么时候调用 load_plugin_textdomain ？基本原则是越晚越好，因为有些多语言的插件可以造成一些地域性属性值的改变，但它又需要在 __()， __e（）这些函数被调用之前。<br />
我在我一个叫 superit 插件（它自带文件夹）里使用的方法 是将下面这段代码放在 functions.php 文件里：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p264code17'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26417"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p264code17"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span>p
add_action <span style="color: #009900;">&#40;</span>’init’<span style="color: #339933;">,</span> ‘my_plugin_init’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_plugin_init <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
load_plugin_textdomain <span style="color: #009900;">&#40;</span>’superit’<span style="color: #339933;">,</span><span style="color: #0000ff;">'wp-content/plugins/superit’);
}
--&gt;</span></pre></td></tr></table></div>

<p>当然，在主题本地化中就是用 load_theme_textdomain（$domain）了，理由见上。所以我的叫 superit 的主题应该有这样的代码：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p264code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26418"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p264code18"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span>p
add_action <span style="color: #009900;">&#40;</span>’init’<span style="color: #339933;">,</span> ‘my_theme_init’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_theme_init <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
load_theme_textdomain <span style="color: #009900;">&#40;</span>’superit’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">--&gt;</span></pre></td></tr></table></div>

<p>如果在使用过程中收到 header error 的错误信息，将这段代码取消就没事了。所以提醒大家注意这个load_plugin_textdomain 和 load_theme_textdomain 的位置。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/ACMv4-5VxFpj_MFOk9zXtNyD5xU/0/da"><img src="http://feedads.g.doubleclick.net/~a/ACMv4-5VxFpj_MFOk9zXtNyD5xU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ACMv4-5VxFpj_MFOk9zXtNyD5xU/1/da"><img src="http://feedads.g.doubleclick.net/~a/ACMv4-5VxFpj_MFOk9zXtNyD5xU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=uc6jZSspgxU:mPbLh-0tjFQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=uc6jZSspgxU:mPbLh-0tjFQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=uc6jZSspgxU:mPbLh-0tjFQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=uc6jZSspgxU:mPbLh-0tjFQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=uc6jZSspgxU:mPbLh-0tjFQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=uc6jZSspgxU:mPbLh-0tjFQ:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/uc6jZSspgxU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/10/27/wp_develop_i1n/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/10/27/wp_develop_i1n/</feedburner:origLink></item>
		<item>
		<title>三星 F480 F488 手机的彩信上网设置方法</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/ur-_6NnU68s/</link>
		<comments>http://www.ericbess.com/ericblog/2008/10/27/%e4%b8%89%e6%98%9f-f480-f488-%e6%89%8b%e6%9c%ba%e7%9a%84%e5%bd%a9%e4%bf%a1%e4%b8%8a%e7%bd%91%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 08:55:24 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/2008/10/27/%e4%b8%89%e6%98%9f-f480-f488-%e6%89%8b%e6%9c%ba%e7%9a%84%e5%bd%a9%e4%bf%a1%e4%b8%8a%e7%bd%91%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95/</guid>
		<description><![CDATA[一、上网设置
1&#160; .“功能表”-“设定”-“网络设定”-“连接”-“选项”-“创建”；
2.“设定名称”-“中国移动GPRS”
&#160;&#160;&#160;&#160;&#160; “接入名称”-“cmwap”
&#160;&#160;&#160;&#160;&#160; “验证类型”-“普通”
&#160;&#160;&#160;&#160;&#160; “用户ID”-不填
&#160;&#160;&#160;&#160;&#160; “密码”-不填
&#160;&#160;&#160;&#160;&#160; “协议”-“HTTP”
&#160;&#160;&#160;&#160;&#160; “主页”-“http://wap.monterner.com”
&#160;&#160;&#160;&#160;&#160; “代理服务器地址”-“10.0.0.172”
&#160;&#160;&#160;&#160;&#160; “端口”-“80”
&#160;&#160;&#160;&#160;&#160;&#160; 其他不用填写或者改动，储存后退出即可。
3.“功能表”-“浏览器”-“设定”-“浏览器设置”-勾选“中国移动GPRS”
 
 二 彩信设置 
1&#160; 功能表 &#8211; 设定 &#8211; 网络设定 &#8211; 链接 在这里新建一个连接
&#160;&#160;&#160;&#160; 设定名称:移动彩信(可任意取名)
&#160;&#160;&#160;&#160; 接入名称:cmwap
&#160;&#160;&#160;&#160; 验证类型:普通
&#160;&#160;&#160;&#160;&#160;&#160; 用户ID:不填
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 密码:不填
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 协议:HTTP　　
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 主页地址:http://mmsc.monternet.com
&#160;&#160;&#160;&#160; 网关地址:10.0.0.172
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 端口:80
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 安全连接:关
&#160;&#160;&#160;&#160; 延迟时间:300秒
&#160;&#160;&#160;&#160;&#160;&#160; 其他不用填写或者改动，储存后退出即可。
2&#160; 功能表&#8212;信息 &#8211; 设定 &#8211; 彩信 &#8211; 彩信设定 &#8211; 选择刚刚建好的“移动彩信”
]]></description>
			<content:encoded><![CDATA[<h4>一、上网设置</h4>
<p>1&nbsp; .“功能表”-“设定”-“网络设定”-“连接”-“选项”-“创建”；</p>
<p>2.“设定名称”-“中国移动GPRS”</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “接入名称”-“cmwap”</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “验证类型”-“普通”</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “用户ID”-不填</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “密码”-不填</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “协议”-“HTTP”</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “主页”-“<a href="http://wap.monterner.com">http://wap.monterner.com</a>”</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “代理服务器地址”-“10.0.0.172”</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “端口”-“80”</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 其他不用填写或者改动，储存后退出即可。</p>
<p>3.“功能表”-“浏览器”-“设定”-“浏览器设置”-勾选“中国移动GPRS”</p>
<p> <br />
<h4> 二 彩信设置 </h4>
<p>1&nbsp; 功能表 &#8211; 设定 &#8211; 网络设定 &#8211; 链接 在这里新建一个连接</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 设定名称:移动彩信(可任意取名)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 接入名称:cmwap</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 验证类型:普通</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用户ID:不填</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 密码:不填</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 协议:HTTP　　</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 主页地址:<a href="http://mmsc.monternet.com">http://mmsc.monternet.com</a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 网关地址:10.0.0.172</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 端口:80</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 安全连接:关</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 延迟时间:300秒</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 其他不用填写或者改动，储存后退出即可。</p>
<p>2&nbsp; 功能表&#8212;信息 &#8211; 设定 &#8211; 彩信 &#8211; 彩信设定 &#8211; 选择刚刚建好的“移动彩信”</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Xez7HOU4uaZ3-E6YZz_F0Cjg50Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/Xez7HOU4uaZ3-E6YZz_F0Cjg50Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Xez7HOU4uaZ3-E6YZz_F0Cjg50Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/Xez7HOU4uaZ3-E6YZz_F0Cjg50Q/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ur-_6NnU68s:vkPKMtHHNss:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ur-_6NnU68s:vkPKMtHHNss:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=ur-_6NnU68s:vkPKMtHHNss:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ur-_6NnU68s:vkPKMtHHNss:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ur-_6NnU68s:vkPKMtHHNss:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ur-_6NnU68s:vkPKMtHHNss:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/ur-_6NnU68s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/10/27/%e4%b8%89%e6%98%9f-f480-f488-%e6%89%8b%e6%9c%ba%e7%9a%84%e5%bd%a9%e4%bf%a1%e4%b8%8a%e7%bd%91%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/10/27/%e4%b8%89%e6%98%9f-f480-f488-%e6%89%8b%e6%9c%ba%e7%9a%84%e5%bd%a9%e4%bf%a1%e4%b8%8a%e7%bd%91%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95/</feedburner:origLink></item>
		<item>
		<title>WP-Donators Plugin(WP赞助商插件)</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/DE_-Ez31pSw/</link>
		<comments>http://www.ericbess.com/ericblog/2008/10/21/wp-donators/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 15:45:23 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PayPal]]></category>
		<category><![CDATA[WP-Plugin]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=258</guid>
		<description><![CDATA[


Plugin Name: WP-Donators(WP赞助商插件)
Author: Eric Wang
Stable Version: 1.1.1
Author URL: http://www.ericbess.com/ericblog/
Plugin URL: http://wordpress.org/extend/plugins/wp-donators/
Download:http://downloads.wordpress.org/plugin/wp-donators.zip



== Description ==
Monetize your blog!  A lot of features to monetize your blog! Including: Sponsors Box,Text Link ADs,My Target, etc. Supporting  multi-Currency exchange. It&#8217;s will support most popular payment interface in future. ParPal Just the first one.
WORDPRESS赞助商插件WP-DONATORS。可以支持PAYPAL多币种捐赠、广告位售卖、个人目标赞助，并实现自动汇率换算。它有个后台与PAYPAL API实时沟通，返回付款数据，然后把捐赠人赞助商指定的广告与连接放在“捐赠人云广告位”中展示出来。
Multi-Currency Support and Exchange
U.S. Dollars,Australian Dollars,British Pounds,Canadian Dollars,Czech [...]]]></description>
			<content:encoded><![CDATA[<table border="0" width="100%">
<tbody>
<tr>
<td>Plugin Name: WP-Donators(WP赞助商插件)<br />
Author: <a href="http://wordpress.org/extend/plugins/profile/ericbess" target="_blank">Eric Wang</a><br />
Stable Version: 1.1.1<br />
Author URL: http://www.ericbess.com/ericblog/<br />
Plugin URL: <a href="http://wordpress.org/extend/plugins/wp-donators/" target="_blank">http://wordpress.org/extend/plugins/wp-donators/</a><br />
Download:<a href="http://downloads.wordpress.org/plugin/wp-donators.zip">http://downloads.wordpress.org/plugin/wp-donators.zip</a></td>
</tr>
</tbody>
</table>
<h3>== Description ==</h3>
<p>Monetize your blog!  A lot of features to monetize your blog! Including: Sponsors Box,Text Link ADs,My Target, etc. Supporting  multi-Currency exchange. It&#8217;s will support most popular payment interface in future. ParPal Just the first one.</p>
<p>WORDPRESS赞助商插件WP-DONATORS。可以支持PAYPAL多币种捐赠、广告位售卖、个人目标赞助，并实现自动汇率换算。它有个后台与PAYPAL API实时沟通，返回付款数据，然后把捐赠人赞助商指定的广告与连接放在“捐赠人云广告位”中展示出来。</p>
<p><strong>Multi-Currency Support and Exchange<br />
</strong>U.S. Dollars,Australian Dollars,British Pounds,Canadian Dollars,Czech Koruna,Danish Kroner,Hong Kong Dollars,Hungarian Forint,<br />
Japanese Yen,Mexican Peso,New Zealand Dollar&#8217;,Norwegian Kroner,Polish Zlotych,Singapore Dollars,Swedish Kronor,Swiss Franc,Chinese Yuan(RMB) </p>
<h3>== Features ==</h3>
<p><strong>Sponsors Box:</strong> Sponsor donate and submit name/URL or TextLink ad. The information of the latest donors are displayed in the cloud. The more a person donations, the bigger their link will be.<br />
<strong>Text Link ADs:</strong> After Sponsor buy the TextLink Advertising, s/he can leave a TextLink and description on the blog. The more a person payment, the longer their advertising will be.<br />
<strong>My Target:</strong> It will show what your target is, how much it needs. What&#8217;s the progress so far, how much is outstanding. And if someone decide to sponsor money to support the Target, it will provide convenient means of payment.</p>
<h3> == Depend On ==</h3>
<ul>
<li>If your haven&#8217;t the paypal account so far.Please register paypal account:[<a href="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG" target="_blank">PayPal Registration</a>] first.<!-- Begin PayPal Logo --><a href="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG" target="_blank"><img src="http://images.paypal.com/en_US/i/bnr/paypal_mrb_banner.gif" border="0" alt="Sign up for PayPal and start accepting credit card payments instantly." /></a></li>
<li>PHP5, Openssl,fsock.</li>
</ul>
<h3><span id="more-258"></span>== Installation ==</h3>
<p style="padding-left: 30px;">1. Upload <a href="http://downloads.wordpress.org/plugin/wp-donators.zip">WP-Donators.zip</a> to your Wordpress plugins directory, usually `wp-content/plugins/` and unzip the file. It will create a `wp-content/plugins/wp-donators/` directory.<br />
2. Activate the plugin through the &#8216;Plugins&#8217; menu in WordPress.<br />
3. Go to {wp-admin}-&gt;Sponsors set the default setting.<br />
4. Go to the Widgets set the sidebar SponsorBox.<br />
5. Edit the THEME, add the PHP function.</p>
<h3>== Screenshots ==</h3>
<p><a name="demo"></a></p>
<ul>
<li>Sidebar(Global) SponsorBox: Left sidebar this page.</li>
<li>PerPost/Page SponsorBox: under side this post.</li>
<li>Sidebar(Global) TextLinkADs/My Target: Right sidebar this page.</li>
<li>PerPost/Page TextLinkADs/My target: under side this post{<strong>This Page Text Link ADs</strong>}.</li>
</ul>
<p style="TEXT-ALIGN: center"><span style="color: #ff0000;"><em><strong>{Test the plugin :Try to make a small donation on the SponserBox, your name or inputer will been displayed in the sponsors cloud box immediately  and automatically after donation.}</strong></em></span></p>
<p style="text-align: center;"><strong><img class="size-full wp-image-10206 aligncenter" title="screenshot-11" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/10/screenshot-11.jpg" alt="screenshot-11" width="464" height="301" /><br />
Option Setting Page</strong></p>
<h3>== HOW To Do ==</h3>
<h4>= Sponsors Box =</h4>
<ul>
<li><strong>Sidebar(Global) SponsorBox:</strong>Go to the Widgets set the sidebar SponsorBox or add the <code>"&lt;?php if(function_exists('sidebar_sponsor_box')) { sidebar_sponsor_box(); } ?&gt;"</code> to `THEME-&gt;sidebar.php`.</li>
<li><strong>PerPost/Page SponsorBox:</strong>Edit the `THEME-&gt;single.php/page.php` add the <code>"&lt;?php if(function_exists('sponsor_box')) { sponsor_box(); }?&gt;" </code>to correct place, or embed shortcode <img title="Sponsor Box ShortCode" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/10/sponsorbox.png" alt="sponsorbox" width="92" height="15" /> in post/page content.</li>
</ul>
<p style="PADDING-LEFT: 30px"><strong>Advanced Mode</strong>:Just display the simplye Donate Form/Sponsor Cloud, not any display style.</p>
<ol style="padding-left: 30px;">
<li>Display Donate Form: <code>"&lt;?php if(function_exists('donate_form')) { donate_form("Type",[size]); }?&gt;" </code></li>
<li>Display Sponsor Cloud: <code>"&lt;?php if(function_exists('show_sponsor')) { show_sponsor("Type"); }?&gt;" </code></li>
</ol>
<ul style="padding-left: 30px;">
<li>`Type` &#8220;global&#8221; or &#8220;post&#8221; applications range. &#8220;globel&#8221; Play a role in the whole site; &#8220;post&#8221; Play in The current post.</li>
<li>`size` The form input width size,default is &#8220;40&#8243;.</li>
</ul>
<h4>= Text Link Ads =</h4>
<ul>
<li><strong>Sidebar(Global) TextLinkADs: </strong>Edit the `THEME-&gt;sidebar.php`, add the <code>"&lt;?php if(function_exists('sidebar_textads')) { sidebar_textads(); } ?&gt;"</code> to correct place.</li>
<li><strong>PerPost/Page TextLinkADs: </strong>Edit the `THEME-&gt;single.php/page.php`, add the <code>"&lt;?php if(function_exists('textads')) { textads(); }?&gt;" </code>to correct place, or embed shortcode <img title="TextLinkADs ShortCode" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/10/textads1.png" alt="textads1" width="68" height="14" /> in post/page content.</li>
<li><a title="Using_Custom_Fields#Usage" href="http://codex.wordpress.org/Using_Custom_Fields#Usage" target="_blank"><strong>Custom Fields</strong></a><strong> in Post/Page:</strong>
<ol>
<li>`textads_price`:(Text Link ADs price /unit for this page).</li>
<li>`textads_unit` <img src='http://www.ericbess.com/ericblog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> The days of one unit).</li>
</ol>
</li>
</ul>
<h4>=My Target=</h4>
<ul>
<li> <strong>Sidebar(Global) My Target:</strong>Edit the `THEME-&gt;sidebar.php`, Add the &#8220;&lt;?php if(function_exists(&#8217;sidebar_mytarget&#8217;)) { sidebar_mytarget(); }?&gt;&#8221; to correct place.</li>
<li><strong>Per-Post/Page My Target:</strong>Edit the `THEME-&gt;single.php/page.php`, Add the &#8220;&lt;?php if(function_exists(&#8217;mytarget&#8217;)) { mytarget();  }?&gt;&#8221; to correct place, or embed shortcode <img title="My Target ShortCode" src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/10/mytarget.jpg" alt="My Target ShortCode" width="76" height="14" />in post/page content.</li>
<li><a title="Using_Custom_Fields#Usage" href="http://codex.wordpress.org/Using_Custom_Fields#Usage" target="_blank"><strong>Custom Fields</strong></a><strong> in Post/Page:</strong>
<ol>
<li>`target_price`:(My Target price for this page).</li>
<li>`target_initial_value`:(initial My Target paid amount &#8216;&lt; target_price&#8217;  for this page)</li>
</ol>
</li>
</ul>
<h3>== Frequently Asked Questions ==</h3>
<p><strong>How do I change the Original string text and tranlsate the plugin?</strong><br />
Open wp-donations.po file with poedit, create the wp-donators-{WPLANG}.mo file, you can define customization text or translate to your lang with poedit.<br />
<strong><em>How to name wp-donators-{WPLANG}.mo what is {WPLANG} ?</em></strong><br />
config the wp-config.php-&gt;define (&#8217;WPLANG&#8217;, &#8221;);such as:</p>
<ul>
<li>wp-donators-en.mo -&gt; define (&#8217;WPLANG&#8217;, &#8216;en&#8217;); //custonization text</li>
<li>wp-donators-zh_CN.mo -&gt; define (&#8217;WPLANG&#8217;, &#8216;zh_CN&#8217;); //S_chinese</li>
</ul>
<p><strong>How to ensure the authenticity of the payment transaction？</strong><br />
This plugin developed in strict accordance with the <a title="Instant Payment Notification" href="https://www.paypal.com/ipn" target="_blank">PAYPAL IPN</a>.</p>
<p><strong>After my payment, Why no my information/ad displayed on the blog, immediately?</strong><br />
WP-Doantors IPN RESPONSE PROCESS will wait the PAYPAL return a validation informaiton. PAYPAL delays some minutes to send the IPN informantin because of the server busy.</p>
<p><strong>How do I customize the css style?</strong><br />
This plugin display style base on [<a href="http://jquery.com">Jquery UI</a>], you can edit the css style on [<a href="http://jqueryui.com/themeroller/">UI THEME</a>],download it, replace the css file.</p>
<h3>== Release Notes ==</h3>
<p>**1.0** : First internal release;<br />
**1.0.7** : IPN response reinforcement, L10n support;<br />
**1.0.8** : Support Multi-currency;<br />
**1.1.0** : New jquery ui,css;add textlinkads feature;<br />
**1.1.1**: Add new feature:My Target;</p>
<h3>== Need Your Help ==</h3>
<p>* Bugs Report<br />
* Language package .mo .po</p>
<h3 style="text-align: left;"><span style="color: #0000ff;">== This Page Text Link ADs ==</span></h3>
<p><span style="color: #0000ff;"><span style="font-weight: normal;"></span></span></p>
<h3><span style="color: #0000ff;"><span style="font-weight: normal;"><strong>== Sponsor My Target (New Domain and Host service for this plugin)  ==</strong></span></span></h3>
<p><span style="color: #0000ff;"><span style="font-weight: normal;">I want to apply new independent Domain and Host service for this Plugin, it&#8217;s need 350$, could you support me.<br />
</span></span><span style="color: #0000ff;"><span style="font-weight: normal;">Following is this targat progress bar, your can click the &#8220;Support my target&#8221; to make donate. Thanks!<br />
</span></span></p>

<p><a href="http://feedads.g.doubleclick.net/~a/6ccJLKU3ifj5YA3Bd6_ZDkxWdnI/0/da"><img src="http://feedads.g.doubleclick.net/~a/6ccJLKU3ifj5YA3Bd6_ZDkxWdnI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/6ccJLKU3ifj5YA3Bd6_ZDkxWdnI/1/da"><img src="http://feedads.g.doubleclick.net/~a/6ccJLKU3ifj5YA3Bd6_ZDkxWdnI/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=DE_-Ez31pSw:42PkOipLN04:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=DE_-Ez31pSw:42PkOipLN04:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=DE_-Ez31pSw:42PkOipLN04:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=DE_-Ez31pSw:42PkOipLN04:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=DE_-Ez31pSw:42PkOipLN04:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=DE_-Ez31pSw:42PkOipLN04:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/DE_-Ez31pSw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/10/21/wp-donators/feed/</wfw:commentRss>
		<slash:comments>64</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/10/21/wp-donators/</feedburner:origLink></item>
		<item>
		<title>给.JS传递参数的方法</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/8TJyHnhx-cE/</link>
		<comments>http://www.ericbess.com/ericblog/2008/09/13/js-parameter/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 16:27:51 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=255</guid>
		<description><![CDATA[js文件：

?View Code JAVASCRIPT1
2
3
4
5
6
7
8
9
10
11
12
13
var BT_open_wait = 500; //time in millis to wait before showing dialog
var BT_close_wait = 0; //time in millis to wait before closing dialog
var BT_cache_enabled = true;
&#160;
function BT_setOptions&#40;hash&#41;
&#123;
	if&#40;hash&#91;&#34;openWait&#34;&#93; != null&#41;
		BT_open_wait = hash&#91;&#34;openWait&#34;&#93;;
	if&#40;hash&#91;&#34;closeWait&#34;&#93; != null&#41;
		BT_close_wait = hash&#91;&#34;closeWait&#34;&#93;;
	if&#40;hash&#91;&#34;cacheEnabled&#34;&#93; != null&#41;
		BT_cache_enabled = hash&#91;&#34;cacheEnabled&#34;&#93;;
&#125;

HTML传值：

?View Code HTML1
2
3
4
5
6
&#60;script type=&#34;text/javascript&#34; src=&#34;path-to/XXX.js&#34;&#62;&#60;/script&#62; 
&#60;script type=&#34;text/javascript&#34;&#62;
    $(function(){
     [...]]]></description>
			<content:encoded><![CDATA[<p>js文件：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p255code21'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p25521"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p255code21"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> BT_open_wait <span style="color: #339933;">=</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//time in millis to wait before showing dialog</span>
<span style="color: #003366; font-weight: bold;">var</span> BT_close_wait <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//time in millis to wait before closing dialog</span>
<span style="color: #003366; font-weight: bold;">var</span> BT_cache_enabled <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> BT_setOptions<span style="color: #009900;">&#40;</span>hash<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>hash<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;openWait&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		BT_open_wait <span style="color: #339933;">=</span> hash<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;openWait&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>hash<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;closeWait&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		BT_close_wait <span style="color: #339933;">=</span> hash<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;closeWait&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>hash<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;cacheEnabled&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		BT_cache_enabled <span style="color: #339933;">=</span> hash<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;cacheEnabled&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>HTML传值：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p255code22'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p25522"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p255code22"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;path-to/XXX.js&quot;&gt;&lt;/script&gt; 
&lt;script type=&quot;text/javascript&quot;&gt;
    $(function(){
       BT_setOptions({openWait:2000, closeWait:4000, enableCache:false});
    })
&lt;/script&gt;</pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/9Ee84rLGT_OcWy76SZQeYDIhT3I/0/da"><img src="http://feedads.g.doubleclick.net/~a/9Ee84rLGT_OcWy76SZQeYDIhT3I/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/9Ee84rLGT_OcWy76SZQeYDIhT3I/1/da"><img src="http://feedads.g.doubleclick.net/~a/9Ee84rLGT_OcWy76SZQeYDIhT3I/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8TJyHnhx-cE:ER7xjVZBoaQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8TJyHnhx-cE:ER7xjVZBoaQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=8TJyHnhx-cE:ER7xjVZBoaQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8TJyHnhx-cE:ER7xjVZBoaQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8TJyHnhx-cE:ER7xjVZBoaQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=8TJyHnhx-cE:ER7xjVZBoaQ:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/8TJyHnhx-cE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/09/13/js-parameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/09/13/js-parameter/</feedburner:origLink></item>
		<item>
		<title>CSS中关于定位</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/ld2jB5HVcEk/</link>
		<comments>http://www.ericbess.com/ericblog/2008/09/08/css-position/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 08:09:03 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[网站技术]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=252</guid>
		<description><![CDATA[在CSS中关于定位的内容是：position:relative &#124; absolute &#124; static &#124; fixed
static 没有特别的设定，遵循基本的定位规定，不能通过z-index进行层次分级。
relative 不脱离文档流，参考自身静态位置通过 top,bottom,left,right 定位，并且可以通过z-index进行层次分级。
absolute 脱离文档流，通过 top,bottom,left,right 定位。选取其最近的父级定位元素，当父级 position 为 static 时，absolute元素将以body坐标原点进行定位，可以通过z-index进行层次分级。
fixed 固定定位，这里他所固定的对像是可视窗口而并非是body或是父级元素。可通过z-index进行层次分级�
CSS中定位的层叠分级：z-index: auto &#124; namber
relative &#124; absolute &#124; static &#124; fixed这四种定位的方式不一样，我们要找到元素的位置的方法也会随之不一样。
Dom元素提供了三种方式来定位元素：offset，scroll，Client


Dom元素对于offset提供了offsetParent、offsetTop、offsetLeft、offsetWidth、offsetHeight五个方法来定位于元素的相对位置。
offsetParent是指当前元素的相对定位的元素。在IE和FF中定义和解释不一样。在IE中定义为获取定义对象 offsetTop 和 offsetLeft 属性的容器对象的引用。大多数时候offsetParent返回body元素。在IE5中，td的offsetParent是table。可以看出IE中的相对定位与绝对定位的区别不大。都是相对于最上层的元素来定位。在FF中获取文档层次中最近的元素。如果这个元素没有定位，那么就根元素。
offsetParent、parentNode（IE:parentElement）都是指元素的父节点。它们的针对的目标是不一样，功能也不一样。parentNode就是取文档层次中包含该节点的最近节点（直接的父节点）。在FF中对于Attr, Document, DocumentFragment, Entity,和Notation这些父节点，其 parentNode返回null。还有如果没有附加到文档树的元素也是返回null。
 offsetParent是指可视的父节点。如

?View Code HTML1
&#60;body&#62;&#60;form&#62;&#60;input type='text' id='AA'/&#62;&#60;/form&#62;&#60;/body&#62;

。AA的offsetParent是body，而parentNode则是form。在IE中一般都是body。
offsetLeft和offsetTop是指当前元素left或top边到offsetParent的left或top边的距离，包含了当前元素的margin和其offsetParent的padding。不包含offsetParent的border的宽度。
offsetWidth、offsetHeight与offsetLeft、offsetTop的相对offsetParent的方式不一样，它们就是当前元素自身的宽度或高度。它包含border、padding、scrollBar(显示的话)和内容的size(CSS中设定的元素的高度，IE中CSS size指的是包含border的内容大小)。
分析了offset，我们可以发现offsetLeft、offsetTop与CSS中top,left的属性有相通性，offsetLeft、offsetTop只能取值。而我们可以通过CSS中top,left的属性来设定一个元素的相对其它元素的位置（绝对定位，就是相对于body）。
 Dom元素对于scroll提供了scrollWidth、scrollHeigth、scrollTop、scrollLeft。这一组是对于scroll的元素进行操作的。Scroll的Width、Heigth是指元素真实的宽度和高度，它包含被scroll起来的部分。而scrollTop、scrollLeft则是被卷起来的部分的大小。
 Dom元素对于scroll提供了clientWidth、clientHeigth、clientTop、clientLeft。这一组是对于client进行操作的。clientWidth、clientHeigth是元素的内容可视区域的高度或宽度。包含padding，不包含scrollbar 、border、margin。可以看出是元素可视的区域。IE，FF是一样的。clientTop、clientLeft可以看做是topborder或left border的大小。
offsetParent的名字的元素能计算相对位移的父节点，那么对于CSS的定位方式，哪一些是可以计算位移呢，能计算元素和其父节点之间的位移量，首先要其父节点能定位。这个定位就是在CSS中能采用top,left来定其在文档的位置。Body是肯定可以的（0，0）。Body也是元素的终结offsetParent（没有找到就是它了）,absolute、 relative、 fixed都采用可以top,left来定其在文档的位置。也是能计算其位置。而static是不需要top,left来设定其位置， Offset是相对已经定位的元素的位移。元素的offsetParent是其父辈节点中的postiont!= Static的节点。
在IE中http://msdn.microsoft.com/zh-cn/library/system.windows.forms.htmlelement.offsetparent(VS.80).aspx，可以看到其不支持fixed的offsetParent。在mozilla中http://developer.mozilla.org/en/DOM/element.offsetParent，可以看出其给出的如果元素没有定位（non-positioned）就是body。
]]></description>
			<content:encoded><![CDATA[<h5>在CSS中关于定位的内容是：position:relative | absolute | static | fixed</h5>
<p>static 没有特别的设定，遵循基本的定位规定，不能通过z-index进行层次分级。<br />
relative 不脱离文档流，参考自身静态位置通过 top,bottom,left,right 定位，并且可以通过z-index进行层次分级。<br />
absolute 脱离文档流，通过 top,bottom,left,right 定位。选取其最近的父级定位元素，当父级 position 为 static 时，absolute元素将以body坐标原点进行定位，可以通过z-index进行层次分级。<br />
fixed 固定定位，这里他所固定的对像是可视窗口而并非是body或是父级元素。可通过z-index进行层次分级。</p>
<h5>CSS中定位的层叠分级：z-index: auto | namber</h5>
<p>relative | absolute | static | fixed这四种定位的方式不一样，我们要找到元素的位置的方法也会随之不一样。</p>
<h5>Dom元素提供了三种方式来定位元素：offset，scroll，Client</h5>
<p><span id="more-252"></span><br />
<a href='http://www.ericbess.com/ericblog/wp-content/uploads/2008/09/dhtmopos.gif'><img src="http://www.ericbess.com/ericblog/wp-content/uploads/2008/09/dhtmopos.gif" alt="" title="dhtmopos" width="500" height="494" class="aligncenter size-full wp-image-253" /></a></p>
<p>Dom元素对于offset提供了<strong>offsetParent、offsetTop、offsetLeft、offsetWidth、offsetHeight</strong>五个方法来定位于元素的相对位置。<br />
<strong>offsetParent</strong>是指当前元素的相对定位的元素。在IE和FF中定义和解释不一样。在IE中定义为获取定义对象 offsetTop 和 offsetLeft 属性的容器对象的引用。大多数时候offsetParent返回body元素。在IE5中，td的offsetParent是table。可以看出IE中的相对定位与绝对定位的区别不大。都是相对于最上层的元素来定位。在FF中获取文档层次中最近的元素。如果这个元素没有定位，那么就根元素。<br />
<strong>offsetParent、parentNode</strong>（IE:parentElement）都是指元素的父节点。它们的针对的目标是不一样，功能也不一样。parentNode就是取文档层次中包含该节点的最近节点（直接的父节点）。在FF中对于Attr, Document, DocumentFragment, Entity,和Notation这些父节点，其 parentNode返回null。还有如果没有附加到文档树的元素也是返回null。<br />
 offsetParent是指可视的父节点。如</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p252code24'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p25224"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p252code24"><pre class="html" style="font-family:monospace;">&lt;body&gt;&lt;form&gt;&lt;input type='text' id='AA'/&gt;&lt;/form&gt;&lt;/body&gt;</pre></td></tr></table></div>

<p>。AA的offsetParent是body，而parentNode则是form。在IE中一般都是body。<br />
<strong>offsetLeft和offsetTop</strong>是指当前元素left或top边到offsetParent的left或top边的距离，包含了当前元素的margin和其offsetParent的padding。不包含offsetParent的border的宽度。<br />
<strong>offsetWidth、offsetHeight</strong>与offsetLeft、offsetTop的相对offsetParent的方式不一样，它们就是当前元素自身的宽度或高度。它包含border、padding、scrollBar(显示的话)和内容的size(CSS中设定的元素的高度，IE中CSS size指的是包含border的内容大小)。<br />
分析了offset，我们可以发现offsetLeft、offsetTop与CSS中top,left的属性有相通性，offsetLeft、offsetTop只能取值。而我们可以通过CSS中top,left的属性来设定一个元素的相对其它元素的位置（绝对定位，就是相对于body）。</p>
<p> Dom元素对于scroll提供了<strong>scrollWidth、scrollHeigth、scrollTop、scrollLeft</strong>。这一组是对于scroll的元素进行操作的。Scroll的Width、Heigth是指元素真实的宽度和高度，它包含被scroll起来的部分。而scrollTop、scrollLeft则是被卷起来的部分的大小。</p>
<p> Dom元素对于scroll提供了<strong>clientWidth、clientHeigth、clientTop、clientLeft</strong>。这一组是对于client进行操作的。clientWidth、clientHeigth是元素的内容可视区域的高度或宽度。包含padding，不包含scrollbar 、border、margin。可以看出是元素可视的区域。IE，FF是一样的。clientTop、clientLeft可以看做是topborder或left border的大小。</p>
<p>offsetParent的名字的元素能计算相对位移的父节点，那么对于CSS的定位方式，哪一些是可以计算位移呢，能计算元素和其父节点之间的位移量，首先要其父节点能定位。这个定位就是在CSS中能采用top,left来定其在文档的位置。Body是肯定可以的（0，0）。Body也是元素的终结offsetParent（没有找到就是它了）,absolute、 relative、 fixed都采用可以top,left来定其在文档的位置。也是能计算其位置。而static是不需要top,left来设定其位置， Offset是相对已经定位的元素的位移。元素的offsetParent是其父辈节点中的postiont!= Static的节点。<br />
在IE中http://msdn.microsoft.com/zh-cn/library/system.windows.forms.htmlelement.offsetparent(VS.80).aspx，可以看到其不支持fixed的offsetParent。在mozilla中http://developer.mozilla.org/en/DOM/element.offsetParent，可以看出其给出的如果元素没有定位（non-positioned）就是body。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/LZWuHEQUQtadrJ-uE6UYhjaM2LA/0/da"><img src="http://feedads.g.doubleclick.net/~a/LZWuHEQUQtadrJ-uE6UYhjaM2LA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/LZWuHEQUQtadrJ-uE6UYhjaM2LA/1/da"><img src="http://feedads.g.doubleclick.net/~a/LZWuHEQUQtadrJ-uE6UYhjaM2LA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ld2jB5HVcEk:NjmBOexaRlw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ld2jB5HVcEk:NjmBOexaRlw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=ld2jB5HVcEk:NjmBOexaRlw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ld2jB5HVcEk:NjmBOexaRlw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ld2jB5HVcEk:NjmBOexaRlw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=ld2jB5HVcEk:NjmBOexaRlw:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/ld2jB5HVcEk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/09/08/css-position/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/09/08/css-position/</feedburner:origLink></item>
		<item>
		<title>请不要被短视所蒙蔽，中国人请珍惜自家的产业！</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/CVQUkdTPhSs/</link>
		<comments>http://www.ericbess.com/ericblog/2008/09/07/251/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 17:10:15 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[投资感想]]></category>
		<category><![CDATA[财金与投资]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=251</guid>
		<description><![CDATA[证监会可交债征求意见，无非是为了通过限制大小非来救市。我不认为能起到好作用，两个方面：
1、可交债对股市不利。
2、大小非解禁（全流通）对市场意义重大，对于价值投资绝对利好，不用限制�
先说可交债:
1.发行可交债抽离市场资金。
2.大非发可交债的目的是在不丧失控股权地位的前提下低息融资。也就是说发行可交债后，发行人一定要打压二级市场股价，以防股权易手。
3.从利益最大化分析。只有那些原本不愿抛售的大非（保持控股地位）会发行可交债，那些原本打算抛的大小非可交债对他们根本无任何诱惑。
大小非解禁：
大小非解禁的核心是全流通，只有全流通的公司才能在市场中完全体现股权价值，这样才能真正吸引有实力的产业资本角逐市场，全流通是市场领域的“自由于民主”。无能的老东家不行了，要卖家产就卖吧，换个有实力的东家对大家都有利。大家想想汇源。再看看现在的市场：16亿美元的金地地产，10亿美元的中华企业，5亿美元的韶钢，对比一下近日大摩与黑石分别100多亿美元的中国地产定向基金，米塔尔百亿美元的全球收购。
这个市场真正的祸首是机构与人心：
6000点上方时机构说：还有上涨空间，继续持有。
5000点时机构说：毫不犹豫建仓（春播秋收）。
4500点机构又说：下跌空间相对有限（这句话一直说到现在）。
4000点机构说：反弹一烛即发，缝低吸入，继续持有。
3500点机构说：逢低介入，谨慎持有。
3000点机构说：底部再现，政策底，反转即将开始。
2500点机构说：轻仓观望，逢高出局。
2300点观望为宜.
2200,有效击破2245强支撑, 下跌空间打开, 控制仓位.
股民们什么心理变化？
股民朋友们请不要再被短视所蒙蔽，中国人请珍惜自家的产业吧！
]]></description>
			<content:encoded><![CDATA[<p>证监会可交债征求意见，无非是为了通过限制大小非来救市。我不认为能起到好作用，两个方面：<br />
1、可交债对股市不利。<br />
2、大小非解禁（全流通）对市场意义重大，对于价值投资绝对利好，不用限制。</p>
<h5>先说可交债:</h5>
<p>1.发行可交债抽离市场资金。<br />
2.大非发可交债的目的是在不丧失控股权地位的前提下低息融资。也就是说发行可交债后，发行人一定要打压二级市场股价，以防股权易手。<br />
3.从利益最大化分析。只有那些原本不愿抛售的大非（保持控股地位）会发行可交债，那些原本打算抛的大小非可交债对他们根本无任何诱惑。</p>
<h5>大小非解禁：</h5>
<p>大小非解禁的核心是全流通，只有全流通的公司才能在市场中完全体现股权价值，这样才能真正吸引有实力的产业资本角逐市场，全流通是市场领域的“自由于民主”。无能的老东家不行了，要卖家产就卖吧，换个有实力的东家对大家都有利。大家想想汇源。再看看现在的市场：16亿美元的金地地产，10亿美元的中华企业，5亿美元的韶钢，对比一下近日大摩与黑石分别100多亿美元的中国地产定向基金，米塔尔百亿美元的全球收购。</p>
<h5>这个市场真正的祸首是机构与人心：</h5>
<p>6000点上方时机构说：还有上涨空间，继续持有。<br />
5000点时机构说：毫不犹豫建仓（春播秋收）。<br />
4500点机构又说：下跌空间相对有限（这句话一直说到现在）。<br />
4000点机构说：反弹一烛即发，缝低吸入，继续持有。<br />
3500点机构说：逢低介入，谨慎持有。<br />
3000点机构说：底部再现，政策底，反转即将开始。<br />
2500点机构说：轻仓观望，逢高出局。<br />
2300点观望为宜.<br />
2200,有效击破2245强支撑, 下跌空间打开, 控制仓位.<br />
股民们什么心理变化？</p>
<p><strong>股民朋友们请不要再被短视所蒙蔽，中国人请珍惜自家的产业吧！</strong></p>

<p><a href="http://feedads.g.doubleclick.net/~a/EXG_qdvGjSoVvQ2NALgn0B7tARU/0/da"><img src="http://feedads.g.doubleclick.net/~a/EXG_qdvGjSoVvQ2NALgn0B7tARU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/EXG_qdvGjSoVvQ2NALgn0B7tARU/1/da"><img src="http://feedads.g.doubleclick.net/~a/EXG_qdvGjSoVvQ2NALgn0B7tARU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=CVQUkdTPhSs:zcu6USGTxeo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=CVQUkdTPhSs:zcu6USGTxeo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=CVQUkdTPhSs:zcu6USGTxeo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=CVQUkdTPhSs:zcu6USGTxeo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=CVQUkdTPhSs:zcu6USGTxeo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=CVQUkdTPhSs:zcu6USGTxeo:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/CVQUkdTPhSs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/09/07/251/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/09/07/251/</feedburner:origLink></item>
		<item>
		<title>通过PayPal来美元现钞转换为现汇</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/2GnmQlvKfO0/</link>
		<comments>http://www.ericbess.com/ericblog/2008/08/25/paypay-change/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 00:51:41 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[PayPal]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=262</guid>
		<description><![CDATA[��　中国是汇率管制的国家，居民手中的美元现汇可以转换为美元现钞和人民币现钞，但是美元现钞和人民币现钞却很难转换为美元现汇，今天我介绍一个方法，可以令没有美元的用户也拥有美元现汇的帐户。
　　首先要现解释一下美元现钞和美元现汇的区别，在我国，居民外币储蓄存款有两种账户：现钞户和现汇户。现钞指的是外币的钞票和硬币或以钞票、硬币存入银行所生成的存款。现汇是指以支票、汇款、托收等国际结算方式取得并形成的银行存款。外币现钞只能运送到国外才能起到支付作用，在国内法律是禁止其支付的。根据国家外汇管理有关规定，现钞不能随意换成现汇。个人外汇买卖业务本着钞变钞，汇变汇的原则。国家的外汇管理政策也是鼓励持有现汇、限制持有现钞，因为现汇作为帐面上的资金比现钞更便于外汇管理。
　　由于美元现汇兑换人民币高于美元现钞，且在流通和交易上都比现钞方便，因此一般都建议美元现汇存款不要轻易支取为现钞，以免让手中的外汇贬值。将手中的美元现钞转换为现汇，也可以使得自己的外汇升值，有个一个方法，可以实现现钞转现汇的功能，实现我们手中的美元现钞“升级”为美元现汇。
　　前提条件是，拥有一个招商银行的信用卡，并用这个信用卡开通PayPal.COM的国际帐户。

　　首先，在PayPal用同名再注册一个帐户，这时候，在银行将美元现钞存入招商银行的信用卡，并用这个卡关联的帐号转一笔美元到另外一个同名PayPal帐号，金额和存入信用卡的相同，之后，在那个帐号里，通过支票或者电汇的方式收款，耐心等待一段时间，支票寄到后去银行托收这张支票，托收成功后，存进去的就是美元现汇，这就实现了美元现钞转换为美元现汇。

　　即使你没有美元，由于招商银行的信用卡可以通过人民币还款美元，你一样可以获得美元现汇。这也是通过人民币兑换美元现钞或者现汇的一个方法。不过如果你办理过港澳通行证并申请了一次签注，那么也可以直接去银行兑换几千美元。
　　这个方法是突破外汇管制的一个思路，不过PayPal支票托收可能有些银行不做，另外这种转钱方法不知道是否违反PayPal的使用条例（同名帐户是否允许转钱），因此我也不知道这个方法是否有效，稍后我会实际进行一下验证，看看是否可以实现这个功能。
　　补充一下相关费用：个人PayPal帐户之间转钱：免费；PayPal支票收款：5美元；PayPal电汇收款：20美元；中国银行托收：20人民币。
　　大家如果对PayPal使用比较熟悉，也可以交流一下各自意见。
]]></description>
			<content:encoded><![CDATA[<p>　　中国是汇率管制的国家，居民手中的美元现汇可以转换为美元现钞和人民币现钞，但是美元现钞和人民币现钞却很难转换为美元现汇，今天我介绍一个方法，可以令没有美元的用户也拥有美元现汇的帐户。</p>
<p>　　首先要现解释一下美元现钞和美元现汇的区别，在我国，居民外币储蓄存款有两种账户：现钞户和现汇户。现钞指的是外币的钞票和硬币或以钞票、硬币存入银行所生成的存款。现汇是指以支票、汇款、托收等国际结算方式取得并形成的银行存款。外币现钞只能运送到国外才能起到支付作用，在国内法律是禁止其支付的。根据国家外汇管理有关规定，现钞不能随意换成现汇。个人外汇买卖业务本着钞变钞，汇变汇的原则。国家的外汇管理政策也是鼓励持有现汇、限制持有现钞，因为现汇作为帐面上的资金比现钞更便于外汇管理。</p>
<p>　　由于美元现汇兑换人民币高于美元现钞，且在流通和交易上都比现钞方便，因此一般都建议美元现汇存款不要轻易支取为现钞，以免让手中的外汇贬值。将手中的美元现钞转换为现汇，也可以使得自己的外汇升值，有个一个方法，可以实现现钞转现汇的功能，实现我们手中的美元现钞“升级”为美元现汇。<a href="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG"></a></p>
<p>　　前提条件是，拥有一个招商银行的信用卡，并用这个信用卡开通<a href="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG">PayPal.COM的国际帐户</a>。<br />
<!-- Begin PayPal Logo --><A HREF="https://www.paypal.com/row/mrb/pal=BV4AUWAD94GZG" target="_blank"><IMG  SRC="http://images.paypal.com/en_US/i/bnr/paypal_mrb_banner.gif" BORDER="0" ALT="Sign up for PayPal and start accepting credit card payments instantly."></A><!-- End PayPal Logo --></p>
<p>　　首先，在PayPal用同名再注册一个帐户，这时候，在银行将美元现钞存入招商银行的信用卡，并用这个卡关联的帐号转一笔美元到另外一个同名PayPal帐号，金额和存入信用卡的相同，之后，在那个帐号里，通过支票或者电汇的方式收款，耐心等待一段时间，支票寄到后去银行托收这张支票，托收成功后，存进去的就是美元现汇，这就实现了美元现钞转换为美元现汇。<br />
<span id="more-262"></span><br />
　　即使你没有美元，由于招商银行的信用卡可以通过人民币还款美元，你一样可以获得美元现汇。这也是通过人民币兑换美元现钞或者现汇的一个方法。不过如果你办理过港澳通行证并申请了一次签注，那么也可以直接去银行兑换几千美元。</p>
<p>　　这个方法是突破外汇管制的一个思路，不过PayPal支票托收可能有些银行不做，另外这种转钱方法不知道是否违反PayPal的使用条例（同名帐户是否允许转钱），因此我也不知道这个方法是否有效，稍后我会实际进行一下验证，看看是否可以实现这个功能。</p>
<p>　　补充一下相关费用：个人PayPal帐户之间转钱：免费；PayPal支票收款：5美元；PayPal电汇收款：20美元；中国银行托收：20人民币。</p>
<p>　　大家如果对PayPal使用比较熟悉，也可以交流一下各自意见。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/xjtYh6e5xfOUnLF0R-aQKvLM2kA/0/da"><img src="http://feedads.g.doubleclick.net/~a/xjtYh6e5xfOUnLF0R-aQKvLM2kA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/xjtYh6e5xfOUnLF0R-aQKvLM2kA/1/da"><img src="http://feedads.g.doubleclick.net/~a/xjtYh6e5xfOUnLF0R-aQKvLM2kA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=2GnmQlvKfO0:dP4MfmOeHV8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=2GnmQlvKfO0:dP4MfmOeHV8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=2GnmQlvKfO0:dP4MfmOeHV8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=2GnmQlvKfO0:dP4MfmOeHV8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=2GnmQlvKfO0:dP4MfmOeHV8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=2GnmQlvKfO0:dP4MfmOeHV8:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/2GnmQlvKfO0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/08/25/paypay-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/08/25/paypay-change/</feedburner:origLink></item>
		<item>
		<title>精通jQuery选择器使用[转]</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/lsM0V_RDD9M/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/21/jquery-selectors/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 04:36:04 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=243</guid>
		<description><![CDATA[jQuery 具有一个相当强大的选择器引擎，提供了完整的选择器语法，允许我们选择几乎所有的元素组合。jQuery 的选择器语法主要是基于 CSS3 和 XPath 的，对   CSS3 和 XPath 了解越多，使用 jQuery 时就越显得心应手。有关 CSS 和 XPath，请参阅以下链接：]]></description>
			<content:encoded><![CDATA[<p>jQuery</strong></a> 具有一个相当强大的选择器引擎，提供了完整的选择器语法，允许我们选择几乎所有的元素组合。jQuery 的选择器语法主要是基于 CSS3 和 XPath 的，对   CSS3 和 XPath 了解越多，使用 jQuery 时就越显得心应手。有关 CSS 和 XPath，请参阅以下链接：</p>

<ul>
<li><a href="http://www.w3.org/TR/REC-CSS1#basic-concepts"><strong>CSS 1</strong></a> </li>
<li><a href="http://www.w3.org/TR/REC-CSS2/selector.html"><strong>CSS 2</strong></a> </li>
<li><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215/"><strong>CSS 3</strong></a> </li>
<li><a href="http://www.w3.org/TR/xpath"><strong>xPath</strong></a> </li>
</ul>
<p>值得注意的是， CSS3 并没有得到现今所有浏览器的支持，因此我们很少使用它。然而，我们仍然可以在 jQuery 中使用 CSS3 选择元素，因为   jQuery 具备自己的自定义选择器引擎，并且实现了对 CSS3 的支持。</p>
<p>想了解 jQuery 选择器更多信息，可以访问 jQuery 的官方文档有关<a href="http://docs.jquery.com/DOM/Traversing/Selectors"><strong> Selector</strong></a> 的部分。下面，在原官方文档的基础上作一些简单的翻译和说明。</p>
<p><a name="css_selectors" title="css_selectors" id="css_selectors"></a></p>
<p><strong>1. CSS   选择器（CSS Selectors）</strong></p>
<p>jQuery 完整地支持 CSS 1-3，并且可以在（选择器）表达式里加入自定义的 CSS-like （和xPath）。</p>
<p><span id="more-243"></span></p>
<p>1.1 jQuery   支持的 CSS 选择器语法</p>
<ul>
<li>* 任何 element </li>
<li><strong>E</strong> 类型为 E 的所有element（其实 E 可以是任何 element） </li>
<li><strong>E:nth-child(n)</strong> 一个类型为 E 的   element，它是其父 element 的第 n 个子 element </li>
<li><strong>E:first-child</strong> 一个类型为 E 的   element，它是其父 element 的第一个子 element   （相当于E:nth-child(0)） </li>
<li><strong>E:last-child</strong> 一个类型为 E 的   element，它是其父 element 的最后一个子 element </li>
<li><strong>E:only-child</strong> 一个类型为 E 的   element，它是其父 element 的唯一子 element </li>
<li><strong>E:empty</strong> 一个类型为 E 的用户界面（UI）   element，它没有子 element（包括 文本 element） </li>
<li><strong>E:enabled</strong> 一个类型为 E 的用户界面（UI）   element，它被设置为禁止（disabled） </li>
<li><strong>E:disabled</strong> 一个类型为 E 的用户界面（UI）   element，它被设置为允许（enabled） </li>
<li><strong>E:checked</strong> 一个类型为 E 的用户界面（UI）   element，它处于选中（checked）状态（适用于单选按钮和复选框） </li>
<li><strong>E:selected</strong> 一个类型为 E 的用户界面（UI）   element，它处于被选择（selected）状态（在选择范围内，有一个或多个可供选择的 element ）。注意：selected 属性并不在   CSS 的规范内，但jQuery 提供内部支持 </li>
<li><strong>E.myclass</strong> 一个类型为 E 的 element，它的   class 类是“myclass” </li>
<li><strong>E#myid</strong> 一个类型为 E 的   element，它的 id 是“myid” </li>
<li><strong>E:not(s)</strong> 一个类型为 E 的   element，并且结果集中的 element 不匹配（不包含）选择器 s（用作过滤） </li>
<li><strong>E F</strong> 一个类型为 F 的 element，它是类型为E 的   element 的子孙 element（注意是子孙 element） </li>
<li><strong>E &gt; F</strong> 一个类型为 F 的   element，它是类型为E 的 element 的子 element（注意是子 element） </li>
<li><strong>E + F</strong> 一个类型为 F 的   element，它是紧跟在类型为E 的 element 后面的一个兄弟 element（注意 F 是   E 的兄弟节点，并且是紧跟随其后的一个） </li>
<li><strong>E ~ F</strong> 一个类型为 F 的 element，它是类型为E 的   element 后面的一个兄弟 element（注意 F 是 E 的兄弟节点，并且位置在E 的后面） </li>
<li><strong>E,F,G</strong> 一个类型为 E 的 element，一个类型为 F   的 element，一个类型为 G 的 element（用于选择多个   element）  
<p>1.2   jQuery 支持，但（跟 CSS 规范）有所不同的选择器语法 </p>
<p>不同之处是必须在属性名前加上符号“@”</p>
<ul>
<li><strong>E[@foo]</strong> 一个类型为 E 的 element，它具有属性“foo” </li>
<li><strong>E[@foo=bar]</strong> 一个类型为 E 的   element，它具有属性“foo = bar” </li>
<li><strong>E[@foo^=bar]</strong> 一个类型为 E 的   element，它具有属性“foo“，并且其属性值是以”bar“开头的 </li>
<li><strong>E[@foo$=bar]</strong> 一个类型为 E 的   element，它具有属性“foo“，并且其属性值是以”bar“结尾的 </li>
<li><strong>E[@foo*=bar]</strong> 一个类型为 E 的   element，它具有属性“foo“，并且其属性值包含”bar“ </li>
<li><strong>E[@foo=bar][@baz=bop]</strong> 一个类型为 E 的   element，它具有属性“foo = bar”和属性”baz = bop“ </li>
</ul>
<p>注：以上的“bar”和“bop”均为字符串。</p>
<p>1.3 jQuery   不支持的选择器语法（略）</p>
<p>因为没什么实际的作用，所以这里也不作赘述，想了解详情的可以参阅官方<a href="http://docs.jquery.com/DOM/Traversing/Selectors#CSS_Selectors"><strong>帮助文档</strong></a>。</p>
<p>1.4 Contex 和   Anchoring</p>
<p>可以设置 contex 来 anchor（定位） 选择器，这也是 jQuery 跟 CSS 规范的一个不同之处。用户可以使用语法： $(expr, context) 来设置   context root。默认的 context root 是整个文档。</p>
<p><strong>2. XPath 选择器（XPath   Selectors）</strong></p>
<p>XPath 也是 jQuer 支持的选择器语法之一。jQuery 支持基本的 <a href="http://www.w3.org/TR/xpath"><strong>XPath   语法</strong></a>。下面以一些例子作说明。</p>
<p>2.1   定位路径（Location Paths）</p>
<h3></h3>
<ul>
<li>绝对路径，相对于整个 HTML 文档 </li>
</ul>
<pre> $(”/html/body//p”) $(”body//p”) $(”p/../div”)</pre>
<ul>
<li><strong>相对路径，相对于设置的 context node</strong> “this” </li>
</ul>
<pre>$(”p/*”, this) $(”/p//a”, this)</pre>
<p>2.2 支持 Axis   选择器</p>
<h3></h3>
<ul>
<li><strong>“//” ： 子孙 elements </strong>（div 所有类型为 p 的子孙 elements）<strong> </strong></li>
</ul>
<pre> $(”/div//p”) $(”//div//p”)</pre>
<ul>
<li><strong>“/” </strong><strong>： </strong><strong>子 elements </strong>（div 所有类型为 p   的子 elements） </li>
</ul>
<pre> $(”//div/p”)</pre>
<ul>
<li><strong>“~” </strong><strong>： </strong><strong>兄弟 elements</strong> （div 所有类型为   form 的兄弟 elements） </li>
</ul>
<pre> $(”//div ~ form”)</pre>
<ul>
<li><strong>““..”</strong><strong>： </strong><strong>父 elements </strong>（div 的父   element 下的类型为 p 的子 elements） </li>
</ul>
<pre> $(”//div/../p”)</pre>
<p>2.3   支持谓词语法（Predicates）</p>
<ul>
<li><strong>[@foo]</strong> 具有属性“foo” </li>
</ul>
<pre> $(”//input[@foo]”)</pre>
<ul>
<li><strong>[@foo=’test’]</strong> 具有属性“foo = ‘test’” </li>
</ul>
<pre> $(”//a[@foo = ‘tsxt’]”)</pre>
<ul>
<li><strong>[Nodelist]</strong> 其子孙 elements 匹配 Nodelist（用于过滤） </li>
</ul>
<pre> $(”//div[p]”) $(”//div[p/a]”)</pre>
<p>2.4 jQuery   支持，但（跟 XPath 规范）有所不同的谓词语法（Predicates）</p>
<h3></h3>
<ul>
<li><strong>[last()] or [position()=last()]</strong> becomes <strong>:last</strong>（选择结果集中的最后一个 element） </li>
</ul>
<pre> $(”p:last”)</pre>
<ul>
<li><strong>[0] or [position()=0]</strong> becomes <strong>:eq(0) or :first</strong>（选择结果集中的第个 element） </li>
</ul>
<pre> $(”p:first”) $(”p:eq(0)”)</pre>
<ul>
<li><strong>[position() &lt; 5]</strong> becomes <strong>:lt(5)</strong>（选择结果集中索引大于5的 elements） </li>
</ul>
<pre> $(”p:lt(5)”)</pre>
<ul>
<li><strong>[position() &gt; 2]</strong> becomes <strong>:gt(2)</strong>（选择结果集中索引小于2的 elements） </li>
</ul>
<pre> $(”p:gt(2)”)</pre>
<p>注：“becomes” 前面的是 XPath 的 predicates 语法，后面是等价的   jQuery 语法。</p>
<p><strong>3. jQuery 自定义的选择器（Custom   Selectors）</strong></p>
<p>jQuery 具有一些自定义的选择器语法，这些语法虽然并不在 CSS 和XPath 规范之内，但它们相当的便捷，所在 jQuery   将它们囊括进来。</p>
<p>3.1   自定义选择器（Custom Selectors）</p>
<h3></h3>
<ul>
<li><strong>:even</strong> 结果集中其索引为偶数（双数）的 elements </li>
<li><strong> <img src='http://www.ericbess.com/ericblog/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> dd</strong> 结果集中其索引为奇数（单数）的 elements </li>
<li><strong>:eq(N) and :nth(N)</strong> 选择结果集中索引为 N 的 elements </li>
<li><strong>:gt(N)</strong> 选择结果集中索引大于 N 的 elements </li>
<li><strong>:lt(N)</strong> 选择结果集中索引小于 N 的 elements </li>
<li><strong>:first</strong> 选择结果集中的第一个 element （相当于 eq(0) 或者 nth(0)） </li>
<li><strong>:last</strong> 选择结果集中的最后一个 element </li>
<li><strong>:parent</strong> 在结果集中选择 elements，它必须具有子   elements（包括文本节点）（跟 :empty 相反） </li>
<li><strong>:contains(’test’)</strong> 选择结果集中包含有指定文本的   elements </li>
<li><strong>:visible</strong> 选择所有可见（visible）的   elements（ display 属性的值等于 visible、block、inline，或者 visibility 属性的值等于 visible，不包括   hidden 类型的 elements（关于 hidden 类型，如&lt;input   type=”hidden” …&gt;）） </li>
<li><strong>:hidden</strong> 选择所有隐藏（visible）的   elements（ display 属性的值等于 none，或者 visibility 属性的值等于 hidden，不包括 hidden 类型的   elements（关于 hidden 类型，如&lt;input type=”hidden”   …&gt;）） </li>
</ul>
<p>例子：</p>
<pre> $(”p:first”).css(”fontWeight”,”bold”); $(”div:hidden”).show(); $(”/div:contains(’test’)”, this).hide();</pre>
<p>3.2   表单选择器（Form Selectors）</p>
<ul>
<li><strong>:input</strong> 选择所有表单 elements（input,   select, textarea, button） </li>
<li><strong>:text</strong> 选择所有文本域 (type=”text”). </li>
<li><strong>:password</strong> 选择所有密码域   (type=”password”). </li>
<li><strong>:radio</strong> 选择所有单选按钮 (type=”radio”). </li>
<li><strong>:checkbox</strong> 选择所有复选框   (type=”checkbox”). </li>
<li><strong>:submit</strong> 选择所有提交按钮   (type=”submit”). </li>
<li><strong>:image</strong> 选择所有图像域 (type=”image”). </li>
<li><strong>:reset</strong> 选择所有重置按钮 (type=”reset”). </li>
<li><strong>:button</strong> 选择所有按钮 (type=”button”). </li>
<li><strong>:file</strong> 选择所有 &lt;input   type=”file”&gt;. </li>
</ul>
<p><strong>:hidden</strong> 也是可用的，在上面的3.1 节有介绍。</p>
<p>建议在使用表单选择时提供一个 context root，例子：</p>
<pre>$(’#myForm :input’)</pre>
<pre>$(’input:radio’, myForm)</pre>
<p>上面最后的一行语句将会选择所有的“myForm”表单里的所有单选按钮，相当于[@type=radio]（即   $(”[@type = radio],myForm”)），但用表单选择器会稍微快点，尤其对于大型的表单。</p>
<p>3.3   更多选择器</p>
<p>jQuery 选择器可以通过第三方的插件来扩展：</p>
<ul>
<li><a title="http://www.softwareunity.com/sandbox/JQueryMoreSelectors/" href="http://www.softwareunity.com/sandbox/JQueryMoreSelectors/">More Selectors Plugin</a> </li>
<li><a title="http://www.malsup.com/jquery/expr/" href="http://www.malsup.com/jquery/expr/">Mike Alsup on   Custom Selectors</a> </li>
<li><a title="http://jquery.com/dev/bugs/bug/312/" href="http://jquery.com/dev/bugs/bug/312/">Patch</a> to allow selection by CSS property (full plugin to be released simultaneously   with 1.1) </li>
</ul>
<p><strong>参考资料</strong>：</p>
<p><a href="http://docs.jquery.com/DOM/Traversing/Selectors" target="_blank">http://docs.jquery.com/DOM/Traversing/Selectors</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/wnl3G5_KCn7uXtQyB6rsjOcKvD8/0/da"><img src="http://feedads.g.doubleclick.net/~a/wnl3G5_KCn7uXtQyB6rsjOcKvD8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/wnl3G5_KCn7uXtQyB6rsjOcKvD8/1/da"><img src="http://feedads.g.doubleclick.net/~a/wnl3G5_KCn7uXtQyB6rsjOcKvD8/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=lsM0V_RDD9M:KWTVrZdISyM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=lsM0V_RDD9M:KWTVrZdISyM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=lsM0V_RDD9M:KWTVrZdISyM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=lsM0V_RDD9M:KWTVrZdISyM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=lsM0V_RDD9M:KWTVrZdISyM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=lsM0V_RDD9M:KWTVrZdISyM:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/lsM0V_RDD9M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/21/jquery-selectors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/21/jquery-selectors/</feedburner:origLink></item>
		<item>
		<title>Jquery效果：实现“即点即改”</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/3YSy-6UfUng/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/20/jquery-editinplace/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 11:49:42 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[网站技术]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=242</guid>
		<description><![CDATA[目标
一个用AJAX（或AHAH）技术设计的页面，访问者无需离开就可以在看到的(x)HTML 页面上编辑内容�
方案
点击需要编辑的文本，变幻出一个带有保存和取消按钮的textarea。修改的部分将通过AHAH传送至服务器端的一个PHP脚本文件，用来更新数据库（MySQL或普通文件）。
演示
AJAX式即点即改演示
在这第一个演示中，我使用了一个id为“editinplace”的div元素。当鼠标划过这里时，背景颜色将变成浅黄色。点击文本将启动一些DOM操作，div元素被一个textarea元素取代–内中包含原先的文本。
点击保存按钮将向服务器端的PHP脚本文件发送新的HTML内容，并重新输出收到的新文本内容（通过 $_POST）。
在真实应用环境下，你还应当添加一个安全性检测，然后才能更新数据库并返回更新后的页面内容，同事告知jQuery执行成功的信息。
但在这个例子中，所有的修改都是成功的，发送给PHP脚本的信息将原封不动的返回到jQuery代码，显示到一个普通的警告窗口里。
代码

?View Code JAVASCRIPT1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$&#40;document&#41;.ready&#40;function&#40;&#41;&#123;
	setClickable&#40;&#41;;
&#125;&#41;;
&#160;
function setClickable&#40;&#41; &#123;
	$&#40;'#editInPlace'&#41;.click&#40;function&#40;&#41; &#123;
		var textarea = '&#60;div&#62;&#60;textarea rows=&#34;10&#34; cols=&#34;60&#34;&#62;'+$&#40;this&#41;.html&#40;&#41;+'&#60;/textarea&#62;';
		var button	 = '&#60;div&#62;&#60;input type=&#34;button&#34; value=&#34;SAVE&#34; class=&#34;saveButton&#34; /&#62; OR &#60;input type=&#34;button&#34; value=&#34;CANCEL&#34; class=&#34;cancelButton&#34; /&#62;&#60;/div&#62;&#60;/div&#62;';
		var revert = $&#40;this&#41;.html&#40;&#41;;
		$&#40;this&#41;.after&#40;textarea+button&#41;.remove&#40;&#41;;
		$&#40;'.saveButton'&#41;.click&#40;function&#40;&#41;&#123;saveChanges&#40;this, false&#41;;&#125;&#41;;
		$&#40;'.cancelButton'&#41;.click&#40;function&#40;&#41;&#123;saveChanges&#40;this, revert&#41;;&#125;&#41;;
	&#125;&#41;
	.mouseover&#40;function&#40;&#41; &#123;
		$&#40;this&#41;.addClass&#40;&#34;editable&#34;&#41;;
	&#125;&#41;
	.mouseout&#40;function&#40;&#41; &#123;
		$&#40;this&#41;.removeClass&#40;&#34;editable&#34;&#41;;
	&#125;&#41;;
&#125;;
&#160;
function saveChanges&#40;obj, cancel&#41; &#123;
	if&#40;!cancel&#41; &#123;
		var t = $&#40;obj&#41;.parent&#40;&#41;.siblings&#40;0&#41;.val&#40;&#41;;
		$.post&#40;&#34;test2.php&#34;,&#123;
  		content: t
		&#125;,function&#40;txt&#41;&#123;
			alert&#40; txt&#41;;
		&#125;&#41;;
	&#125;else &#123;
		var t = cancel;
	&#125;
	if&#40;t==''&#41; t='(click to add text)';
	$&#40;obj&#41;.parent&#40;&#41;.parent&#40;&#41;.after&#40;'&#60;div id=&#34;editInPlace&#34;&#62;'+t+'&#60;/div&#62;'&#41;.remove&#40;&#41;;
	setClickable&#40;&#41;;
&#125;


?View Code CSS1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
body&#123;
	font-family: [...]]]></description>
			<content:encoded><![CDATA[<h5>目标</h5>
<p>一个用AJAX（或AHAH）技术设计的页面，访问者无需离开就可以在看到的(x)<acronym title="HyperText Markup Language">HTML</acronym> 页面上编辑内容。</p>
<h5>方案</h5>
<p>点击需要编辑的文本，变幻出一个带有保存和取消按钮的textarea。修改的部分将通过AHAH传送至服务器端的一个PHP脚本文件，用来更新数据库（MySQL或普通文件）。</p>
<h5>演示</h5>
<p><a title="http://15daysofjquery.com/examples/jqueryEditInPlace/divEdit.php" href="http://15daysofjquery.com/examples/jqueryEditInPlace/divEdit.php" rel="nofollow">AJAX式即点即改演示</a><br />
在这第一个演示中，我使用了一个id为“editinplace”的div元素。当鼠标划过这里时，背景颜色将变成浅黄色。点击文本将启动一些DOM操作，div元素被一个textarea元素取代–内中包含原先的文本。<br />
点击保存按钮将向服务器端的PHP脚本文件发送新的HTML内容，并重新输出收到的新文本内容（通过 $_POST）。<br />
在真实应用环境下，你还应当添加一个安全性检测，然后才能更新数据库并返回更新后的页面内容，同事告知jQuery执行成功的信息。<span id="more-242"></span></p>
<blockquote><p>但在这个例子中，所有的修改都是成功的，发送给PHP脚本的信息将原封不动的返回到jQuery代码，显示到一个普通的警告窗口里。</p></blockquote>
<h5>代码</h5>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p242code27'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p24227"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code" id="p242code27"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	setClickable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> setClickable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#editInPlace'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> textarea <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;div&gt;&lt;textarea rows=&quot;10&quot; cols=&quot;60&quot;&gt;'</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;/textarea&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> button	 <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;div&gt;&lt;input type=&quot;button&quot; value=&quot;SAVE&quot; class=&quot;saveButton&quot; /&gt; OR &lt;input type=&quot;button&quot; value=&quot;CANCEL&quot; class=&quot;cancelButton&quot; /&gt;&lt;/div&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> revert <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">after</span><span style="color: #009900;">&#40;</span>textarea<span style="color: #339933;">+</span>button<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.saveButton'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>saveChanges<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.cancelButton'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>saveChanges<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> revert<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #660066;">mouseover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;editable&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #660066;">mouseout</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;editable&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> saveChanges<span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> cancel<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>cancel<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> t <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;test2.php&quot;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
  		content<span style="color: #339933;">:</span> t
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>txt<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> txt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> t <span style="color: #339933;">=</span> cancel<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>t<span style="color: #339933;">==</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> t<span style="color: #339933;">=</span><span style="color: #3366CC;">'(click to add text)'</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">after</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;editInPlace&quot;&gt;'</span><span style="color: #339933;">+</span>t<span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	setClickable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p242code28'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p24228"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p242code28"><pre class="css" style="font-family:monospace;">body<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> arial<span style="color: #00AA00;">,</span> helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> small<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.editable</span><span style="color: #00AA00;">,</span> textarea<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ffffd3</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
textarea<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">95</span>%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
img.progress<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">middle</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> 0 <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/vARektMq48QqIm1trab6WeBYSbU/0/da"><img src="http://feedads.g.doubleclick.net/~a/vARektMq48QqIm1trab6WeBYSbU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vARektMq48QqIm1trab6WeBYSbU/1/da"><img src="http://feedads.g.doubleclick.net/~a/vARektMq48QqIm1trab6WeBYSbU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3YSy-6UfUng:VdJlrvEb-os:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3YSy-6UfUng:VdJlrvEb-os:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=3YSy-6UfUng:VdJlrvEb-os:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3YSy-6UfUng:VdJlrvEb-os:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3YSy-6UfUng:VdJlrvEb-os:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=3YSy-6UfUng:VdJlrvEb-os:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/3YSy-6UfUng" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/20/jquery-editinplace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/20/jquery-editinplace/</feedburner:origLink></item>
		<item>
		<title>Jquery效果：样式表切换</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/18KS08TFzjg/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/20/switchstylestyle/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 08:42:31 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[网站技术]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=241</guid>
		<description><![CDATA[DEMO]]></description>
			<content:encoded><![CDATA[<p><a title="http://www.kelvinluck.com/assets/jquery/styleswitch/" href="http://www.kelvinluck.com/assets/jquery/styleswitch/" rel="nofollow">DEMO</a></p>
<h5>熟悉的开篇 </h5>
<div class=example>
$(document).ready(function(){<br />
  $(&#8217;.styleswitch&#8217;).click(function()
</div>
<p>告诉jQuery“以最快的速度查找所有包含对象名‘styleswitch’的元素，并在他们被鼠标点击时执行一个函数”。<br />
看起来不错。当鼠标点击预先指定的元素时，switchStylestyle函数将被调用。从现在开始是重点。 </p>
<blockquote><p>$(&#8217;link[@rel*=style]&#8216;).each(function(i) { </p></blockquote>
<p>这句话什么意思？<br />
找到了jQuery的作者John Resig，向他咨询。他直接给了我一个jQuery网站的页面地址，里面讲解了若干jQuery提供的高级特性(xpath)，可以用来查找并操作页面中的若干元素。如果你看过这些东西你就能明白上面那句神秘的代码的含义是告诉jQuery“查找所有带rel属性并且属性值字符串中包含‘style’的link链接元素”。<br />
<span id="more-241"></span><br />
让我们看看如何编写包含一个主样式表，两个备用样式表的页面：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p241code32'); return false;">View Code</a> HEAD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p24132"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p241code32"><pre class="head" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles1.css&quot; title=&quot;styles1&quot; media=&quot;screen&quot; /&gt;
&lt;link rel=&quot;alternate stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles2.css&quot; title=&quot;styles2&quot; media=&quot;screen&quot; /&gt;
&lt;link rel=&quot;alternate stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles3.css&quot; title=&quot;styles3&quot; media=&quot;screen&quot; /&gt;</pre></td></tr></table></div>

<p>我们可以看到所有样式表都含有一个包含‘style’字串的rel属性。 所以结果一目了然，jQuery轻松定位了页面中的样式表链接。 </p>
<h5>
下一步？<br />
</h5>
<p>each()函数将遍历所有这些样式表链接，并执行下一行中的代码： </p>
<blockquote><p>this.disabled = true;<br />
if (this.getAttribute(&#8217;title&#8217;) == styleName) this.disabled = false;</p></blockquote>
<p>“首先禁用所有的样式表链接，然后开启任何title属性值与switchStylestyle函数传递过来的字串相同的样式表”<br />
一把抓啊，不过很有效。 </p>
<h5>代码</h5>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p241code33'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p24133"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p241code33"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.styleswitch'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		switchStylestyle<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> switchStylestyle<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> switchStylestyle<span style="color: #009900;">&#40;</span>styleName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'link[@rel*=style]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> styleName<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	createCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #339933;">,</span> styleName<span style="color: #339933;">,</span> 365<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h5>
HTML部分<br />
</h5>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p241code34'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p24134"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p241code34"><pre class="html" style="font-family:monospace;">&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;serversideSwitch.html?style=style1&quot; rel=&quot;styles1&quot; class=&quot;styleswitch&quot;&gt;styles1&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;serversideSwitch.html?style=style2&quot; rel=&quot;styles2&quot; class=&quot;styleswitch&quot;&gt;styles2&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;serversideSwitch.html?style=style3&quot; rel=&quot;styles3&quot; class=&quot;styleswitch&quot;&gt;styles3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/wvTDMeNSwbOF3nalLUAHC3lGAUI/0/da"><img src="http://feedads.g.doubleclick.net/~a/wvTDMeNSwbOF3nalLUAHC3lGAUI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/wvTDMeNSwbOF3nalLUAHC3lGAUI/1/da"><img src="http://feedads.g.doubleclick.net/~a/wvTDMeNSwbOF3nalLUAHC3lGAUI/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=18KS08TFzjg:uorRxaWcYOo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=18KS08TFzjg:uorRxaWcYOo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=18KS08TFzjg:uorRxaWcYOo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=18KS08TFzjg:uorRxaWcYOo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=18KS08TFzjg:uorRxaWcYOo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=18KS08TFzjg:uorRxaWcYOo:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/18KS08TFzjg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/20/switchstylestyle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/20/switchstylestyle/</feedburner:origLink></item>
		<item>
		<title>PHP FixPath Function[路径整理函数]</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/UcM9Ku8SQXc/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/17/fixpath/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 11:40:47 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=240</guid>
		<description><![CDATA[FixPath Function: fix the dirty paths. PHP路径整理函数.
Example:

?View Code PHP1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
&#60;?php
echo &#34;nnn    Dirty paths:n&#34;;
$paths&#91;&#93; = 'C://////////Windows//////System';               //  C:/System
$paths&#91;&#93; = 'C:HTMLjavascript..examplescolors.html';    //  C:/HTML/examples/colors.html
$paths&#91;&#93; = '/root/./wwwroot/scripts/../././webpage';        //  /root/wwwroot/webpage
$paths&#91;&#93; = [...]]]></description>
			<content:encoded><![CDATA[<p>FixPath Function: fix the dirty paths. PHP路径整理函数.<br />
Example:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p240code37'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p24037"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p240code37"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;nnn    Dirty paths:n&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'C://////////Windows//////System'</span><span style="color: #339933;">;</span>               <span style="color: #666666; font-style: italic;">//  C:/System</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'C:HTMLjavascript..examplescolors.html'</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">//  C:/HTML/examples/colors.html</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/root/./wwwroot/scripts/../././webpage'</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">//  /root/wwwroot/webpage</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'wwwroot/webpage/../index.php?querystring'</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">//  wwwroot/index.php?querystring</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.php.net/manual/en/../../downloads'</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//  http://www.php.net/downloads</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.php.net/downloads/test/test1/test2//./docs.php'</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">//  http://www.php.net/docs.php</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'../downloads/../docs.php'</span><span style="color: #339933;">;</span>                      <span style="color: #666666; font-style: italic;">//  ../docs.php</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'localhost//projetos/../_arquivos/../'</span><span style="color: #339933;">;</span>          <span style="color: #666666; font-style: italic;">//   &quot;&quot;</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'C:/downloads/../../../'</span><span style="color: #339933;">;</span>                        <span style="color: #666666; font-style: italic;">//  C:/</span>
<span style="color: #000088;">$paths</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'downloads/../../../'</span><span style="color: #339933;">;</span>                           <span style="color: #666666; font-style: italic;">//  ../../</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$paths</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;n&amp;quot;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&amp;quot;  =  &amp;quot;&quot;</span> <span style="color: #339933;">.</span> fixpath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&amp;quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<div class='note'>
Note: &#8220;//&#8221; one more slashes will roll back the root.
</div>
<p><span id="more-240"></span><br />
Function:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.ericbess.com/ericblog/wp-content/plugins/wp-codebox/wp-codebox.php?p=240&amp;download=FixPath.php">FixPath.php</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p24038"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
</pre></td><td class="code" id="p240code38"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> fixpath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Sanity check</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Converts all &quot;&quot; to &quot;/&quot;, and erases blank spaces at the beginning and the ending of the string</span>
    <span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/*   Breaks the original string in to parts: &quot;root&quot; and &quot;dir&quot;.
    *    &quot;root&quot; can be &quot;C:/&quot; (Windows), &quot;/&quot; (Linux) or &quot;http://www.something.com/&quot; (URLs). This will be the start of output string.
    *    &quot;dir&quot; can be &quot;Windows/System&quot;, &quot;root/html/examples/&quot;, &quot;includes/classes/class.validator.php&quot;, etc.
    */</span>
    <a href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/^(/|w:/|(http|ftp)s?://[^/]+/)?(.*)$/i&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$path_root</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>1<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$path_dir</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>3<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//  If &quot;dir&quot; part has one or more slashes at the beginning, erases all.</span>
    <span style="color: #000088;">$path_dir</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span>  <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/^/+/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>  <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>  <span style="color: #000088;">$path_dir</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Breaks &quot;dir&quot; part on each slash</span>
    <span style="color: #000088;">$path_parts</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path_dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Creates a new array with the right path. Each element is a new dir (or file in the ending, if exists) in sequence.</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> 0<span style="color: #339933;">,</span> <span style="color: #000088;">$real_path_parts</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_parts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_parts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</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: #009900;">&#123;</span>
            <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_parts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</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;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">!=</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_parts</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span>1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        	<span style="color: #000088;">$real_path_parts</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        	<span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</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;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_parts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</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: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>  <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$real_path_parts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #339933;">-</span>1<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">&amp;&amp;</span>  <span style="color: #000088;">$real_path_parts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</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: #009900;">&#40;</span><span style="color: #000088;">$path_root</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <a href="http://www.php.net/array_pop"><span style="color: #990000;">array_pop</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$real_path_parts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$j</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: #009900;">&#125;</span>
&nbsp;
        <a href="http://www.php.net/array_push"><span style="color: #990000;">array_push</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$real_path_parts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path_parts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$path_root</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$real_path_parts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/w4D0BCSZrVchSywwlgufxzNtVs4/0/da"><img src="http://feedads.g.doubleclick.net/~a/w4D0BCSZrVchSywwlgufxzNtVs4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/w4D0BCSZrVchSywwlgufxzNtVs4/1/da"><img src="http://feedads.g.doubleclick.net/~a/w4D0BCSZrVchSywwlgufxzNtVs4/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=UcM9Ku8SQXc:qliD2gH9rXY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=UcM9Ku8SQXc:qliD2gH9rXY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=UcM9Ku8SQXc:qliD2gH9rXY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=UcM9Ku8SQXc:qliD2gH9rXY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=UcM9Ku8SQXc:qliD2gH9rXY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=UcM9Ku8SQXc:qliD2gH9rXY:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/UcM9Ku8SQXc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/17/fixpath/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/17/fixpath/</feedburner:origLink></item>
		<item>
		<title>FindRelativePath Function[找出路径间相对关系]</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/KX2QAZfM320/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/17/frpath/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 11:13:30 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=239</guid>
		<description><![CDATA[PHP FUNCTION:Found the relative between the path.
PHP函数：找出路径间相对关系。
Example:

?View Code PHP1
2
3
4
5
6
7
8
9
&#60;?php
$path_a = 'http://www.php.net/manual/en/install.php';
$path_b = 'http://www.php.net/downloads';
&#160;
echo &#34;\nPath A:  &#34; . $path_a;
echo &#34;\nPath B:  &#34; . $path_b;
echo &#34;\nA to B:  &#34; . findRelativePath&#40;$path_a, $path_b&#41;; //  ../../downloads/
echo &#34;\nB to A:  &#34; . findRelativePath&#40;$path_b, $path_a&#41;; //  ../manual/en/install.php
?&#62;

Function:


?Download FRPath.php1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
&#60;?php
function findRelativePath&#40;$path_1, $path_2&#41;
&#123;
    if &#40;$path_1 [...]]]></description>
			<content:encoded><![CDATA[<p>PHP FUNCTION:Found the relative between the path.<br />
PHP函数：找出路径间相对关系。</p>
<p>Example:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p239code41'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p23941"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p239code41"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$path_a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.php.net/manual/en/install.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$path_b</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.php.net/downloads'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Path A:  &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$path_a</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Path B:  &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$path_b</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>A to B:  &quot;</span> <span style="color: #339933;">.</span> findRelativePath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path_b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//  ../../downloads/</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>B to A:  &quot;</span> <span style="color: #339933;">.</span> findRelativePath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_b</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path_a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//  ../manual/en/install.php</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Function:<br />
<span id="more-239"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.ericbess.com/ericblog/wp-content/plugins/wp-codebox/wp-codebox.php?p=239&amp;download=FRPath.php">FRPath.php</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p23942"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code" id="p239code42"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> findRelativePath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path_2</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_1</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span>  <span style="color: #339933;">||</span>  <span style="color: #000088;">$path_2</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <a href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/^(<span style="color: #000099; font-weight: bold;">\\</span>/|\w:<span style="color: #000099; font-weight: bold;">\\</span>/|https?:<span style="color: #000099; font-weight: bold;">\\</span>/<span style="color: #000099; font-weight: bold;">\\</span>/[^<span style="color: #000099; font-weight: bold;">\\</span>/]+<span style="color: #000099; font-weight: bold;">\\</span>/)?(.*)$/i&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path_1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches_1</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/^(<span style="color: #000099; font-weight: bold;">\\</span>/|\w:<span style="color: #000099; font-weight: bold;">\\</span>/|https?:<span style="color: #000099; font-weight: bold;">\\</span>/<span style="color: #000099; font-weight: bold;">\\</span>/[^<span style="color: #000099; font-weight: bold;">\\</span>/]+<span style="color: #000099; font-weight: bold;">\\</span>/)?(.*)$/i&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path_2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches_2</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches_1</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>1<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$matches_2</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>1<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$path_1_parts</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches_1</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$path_2_parts</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches_2</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_1_parts</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">&amp;&amp;</span>  <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_2_parts</span><span style="color: #009900;">&#91;</span>0<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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_1_parts</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$path_2_parts</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <a href="http://www.php.net/array_shift"><span style="color: #990000;">array_shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_1_parts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <a href="http://www.php.net/array_shift"><span style="color: #990000;">array_shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_2_parts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> 0<span style="color: #339933;">,</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path_1_parts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$path</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;../&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path_2_parts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/sItqqsx2v1grihGg_8zLwIv8PnA/0/da"><img src="http://feedads.g.doubleclick.net/~a/sItqqsx2v1grihGg_8zLwIv8PnA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/sItqqsx2v1grihGg_8zLwIv8PnA/1/da"><img src="http://feedads.g.doubleclick.net/~a/sItqqsx2v1grihGg_8zLwIv8PnA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=KX2QAZfM320:k-mp3Gc4dk0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=KX2QAZfM320:k-mp3Gc4dk0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=KX2QAZfM320:k-mp3Gc4dk0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=KX2QAZfM320:k-mp3Gc4dk0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=KX2QAZfM320:k-mp3Gc4dk0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=KX2QAZfM320:k-mp3Gc4dk0:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/KX2QAZfM320" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/17/frpath/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/17/frpath/</feedburner:origLink></item>
		<item>
		<title>[转]深入浅出之正则表达式</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/gphEN54UWI0/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/15/regex-2/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 06:11:36 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Regex]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=238</guid>
		<description><![CDATA[前言：
半年前我对正则表达式产生了兴趣，在网上查找过不少资料，看过不少的教程，最后在使用一个正则表达式工具RegexBuddy时发现他的教程写的非常好，可以说是我目前见过最好的正则表达式教程。于是一直想把他翻译过来。这个愿望直到这个五一长假才得以实现，结果就有了这篇文章。关于本文的名字，使用“深入浅出”似乎已经太俗。但是通读原文以后，觉得只有用“深入浅出”才能准确的表达出该教程给我的感受，所以也就不能免俗了。
本文是Jan Goyvaerts为RegexBuddy写的教程的译文，版权归原作者所有，欢迎转载。但是为了尊重原作者和译者的劳动，请注明出处！谢谢！]]></description>
			<content:encoded><![CDATA[<h5>前言：</h5>
<p>半年前我对正则表达式产生了兴趣，在网上查找过不少资料，看过不少的教程，最后在使用一个正则表达式工具RegexBuddy时发现他的教程写的非常好，可以说是我目前见过最好的正则表达式教程。于是一直想把他翻译过来。这个愿望直到这个五一长假才得以实现，结果就有了这篇文章。关于本文的名字，使用“深入浅出”似乎已经太俗。但是通读原文以后，觉得只有用“深入浅出”才能准确的表达出该教程给我的感受，所以也就不能免俗了。</p>
<p>本文是Jan Goyvaerts为RegexBuddy写的教程的译文，版权归原作者所有，欢迎转载。但是为了尊重原作者和译者的劳动，请注明出处！谢谢！</p>

<h5>什么是正则表达式</h5>
<p>基本说来，正则表达式是一种用来描述一定数量文本的模式。Regex代表Regular Express。本文将用&lt;&lt;regex&gt;&gt;来表示一段具体的正则表达式。一段文本就是最基本的模式，简单的匹配相同的文本。</p>
<h5>不同的正则表达式引擎</h5>
<p>正则表达式引擎是一种可以处理正则表达式的软件。通常，引擎是更大的应用程序的一部分。在软件世界，不同的正则表达式并不互相兼容。本教程会集中讨论Perl 5 类型的引擎，因为这种引擎是应用最广泛的引擎。同时我们也会提到一些和其他引擎的区别。许多近代的引擎都很类似，但不完全一样。例如.NET正则库，JDK正则包。</p>
<h5>文字符号</h5>
<p>最基本的正则表达式由单个文字符号组成。如&lt;&lt;a&gt;&gt;，它将匹配字符串中第一次出现的字符“a”。如对字符串“Jack is a boy”。“J”后的“a”将被匹配。而第二个“a”将不会被匹配。正则表达式也可以匹配第二个“a”，这必须是你告诉正则表达式引擎从第一次匹配的地方开始搜索。在文本编辑器中，你可以使用“查找下一个”。在编程语言中，会有一个函数可以使你从前一次匹配的位置开始继续向后搜索。</p>
<p>类似的，&lt;&lt;cat&gt;&gt;会匹配“About cats and dogs”中的“cat”。这等于是告诉正则表达式引擎，找到一个&lt;&lt;c&gt;&gt;，紧跟一个&lt;&lt;a&gt;&gt;，再跟一个&lt;&lt;t&gt;&gt;。</p>
<p>要注意，正则表达式引擎缺省是大小写敏感的。除非你告诉引擎忽略大小写，否则&lt;&lt;cat&gt;&gt;不会匹配“Cat”。</p>
<h5>特殊字符</h5>
<p>对于文字字符，有11个字符被保留作特殊用途。他们是：[ ] \ ^ $ . | ? * + ( )</p>
<p>这些特殊字符也被称作元字符。</p>
<p>如果你想在正则表达式中将这些字符用作文本字符，你需要用反斜杠“\”对其进行换码 (escape)。例如你想匹配“1+1=2”，正确的表达式为&lt;&lt;1\+1=2&gt;&gt;.</p>
<p>需要注意的是，&lt;&lt;1+1=2&gt;&gt;也是有效的正则表达式。但它不会匹配“1+1=2”，而会匹配“123+111=234”中的“111=2”。因为“+”在这里表示特殊含义（重复1次到多次）。</p>
<p>在编程语言中，要注意，一些特殊的字符会先被编译器处理，然后再传递给正则引擎。因此正则表达式&lt;&lt;1\+2=2&gt;&gt;在C++中要写成“1\\+1=2”。为了匹配“C:\temp”，你要用正则表达式&lt;&lt;C:\\temp&gt;&gt;。而在C++中，正则表达式则变成了“C:\\\\temp”。<br />
<span id="more-238"></span></p>
<h5>不可显示字符</h5>
<p>可以使用特殊字符序列来代表某些不可显示字符：&lt;&lt;\t&gt;&gt;代表Tab(0&#215;09)</p>
<p>&lt;&lt;\r&gt;&gt;代表回车符(0&#215;0D)</p>
<p>&lt;&lt;\n&gt;&gt;代表换行符(0&#215;0A)</p>
<p>要注意的是Windows中文本文件使用“\r\n”来结束一行而Unix使用“\n”。</p>
<h5>正则表达式引擎的内部工作机制</h5>
<p>知道正则表达式引擎是如何工作的有助于你很快理解为何某个正则表达式不像你期望的那样工作。有两种类型的引擎：文本导向(text-directed)的引擎和正则导向(regex-directed)的引擎。Jeffrey Friedl把他们称作DFA和NFA引擎。本文谈到的是正则导向的引擎。这是因为一些非常有用的特性，如“惰性”量词(lazy quantifiers)和反向引用(backreferences)，只能在正则导向的引擎中实现。所以毫不意外这种引擎是目前最流行的引擎。</p>
<p>你可以轻易分辨出所使用的引擎是文本导向还是正则导向。如果反向引用或“惰性”量词被实现，则可以肯定你使用的引擎是正则导向的。你可以作如下测试：将正则表达式&lt;&lt;regex|regex not&gt;&gt;应用到字符串“regex not”。如果匹配的结果是regex，则引擎是正则导向的。如果结果是regex not，则是文本导向的。因为正则导向的引擎是“猴急”的，它会很急切的进行表功，报告它找到的第一个匹配 。</p>
<h5>正则导向的引擎总是返回最左边的匹配</h5>
<p>这是需要你理解的很重要的一点：即使以后有可能发现一个“更好”的匹配，正则导向的引擎也总是返回最左边的匹配。当把&lt;&lt;cat&gt;&gt;应用到“He captured a catfish for his cat”，引擎先比较&lt;&lt;c&gt;&gt;和“H”，结果失败了。于是引擎再比较&lt;&lt;c&gt;&gt;和“e”，也失败了。直到第四个字符，&lt;&lt;c&gt;&gt;匹配了“c”。&lt;&lt;a&gt;&gt;匹配了第五个字符。到第六个字符&lt;&lt;t&gt;&gt;没能匹配“p”，也失败了。引擎再继续从第五个字符重新检查匹配性。直到第十五个字符开始，&lt;&lt;cat&gt;&gt;匹配上了“catfish”中的“cat”，正则表达式引擎急切的返回第一个匹配的结果，而不会再继续查找是否有其他更好的匹配。</p>
<h5>字符集</h5>
<p>字符集是由一对方括号“[]”括起来的字符集合。使用字符集，你可以告诉正则表达式引擎仅仅匹配多个字符中的一个。如果你想匹配一个“a”或一个“e”，使用&lt;&lt;[ae]&gt;&gt;。你可以使用&lt;&lt;gr[ae]y&gt;&gt;匹配gray或grey。这在你不确定你要搜索的字符是采用美国英语还是英国英语时特别有用。相反，&lt;&lt;gr[ae]y&gt;&gt;将不会匹配graay或graey。字符集中的字符顺序并没有什么关系，结果都是相同的。你可以使用连字符“-”定义一个字符范围作为字符集。&lt;&lt;[0-9]&gt;&gt;匹配0到9之间的单个数字。你可以使用不止一个范围。&lt;&lt;[0-9a-fA-F] &gt;&gt;匹配单个的十六进制数字，并且大小写不敏感。你也可以结合范围定义与单个字符定义。&lt;&lt;[0-9a-fxA-FX]&gt;&gt;匹配一个十六进制数字或字母X。再次强调一下，字符和范围定义的先后顺序对结果没有影响。</p>
<h5>字符集的一些应用</h5>
<p>查找一个可能有拼写错误的单词，比如&lt;&lt;sep[ae]r[ae]te&gt;&gt; 或 &lt;&lt;li[cs]en[cs]e&gt;&gt;。查找程序语言的标识符，&lt;&lt;A-Za-z_][A-Za-z_0-9]*&gt;&gt;。(*表示重复0或多次)</p>
<p>查找C风格的十六进制数&lt;&lt;0[xX][A-Fa-f0-9]+&gt;&gt;。(+表示重复一次或多次)</p>
<h5>取反字符集</h5>
<p>在左方括号“[”后面紧跟一个尖括号“^”，将会对字符集取反。结果是字符集将匹配任何不在方括号中的字符。不像“.”，取反字符集是可以匹配回车换行符的。需要记住的很重要的一点是，取反字符集必须要匹配一个字符。&lt;&lt;q[^u]&gt;&gt;并不意味着：匹配一个q，后面没有u跟着。它意味着：匹配一个q，后面跟着一个不是u的字符。所以它不会匹配“Iraq”中的q，而会匹配“Iraq is a country”中的q和一个空格符。事实上，空格符是匹配中的一部分，因为它是一个“不是u的字符”。</p>
<p>如果你只想匹配一个q，条件是q后面有一个不是u的字符，我们可以用后面将讲到的向前查看来解决。</p>
<h5>字符集中的元字符</h5>
<p>需要注意的是，在字符集中只有4个 字符具有特殊含义。它们是：“] \ ^ -”。“]”代表字符集定义的结束；“\”代表转义；“^”代表取反；“-”代表范围定义。其他常见的元字符在字符集定义内部都是正常字符，不需要转义。例如，要搜索星号*或加号+，你可以用&lt;&lt;[+*]&gt;&gt;。当然，如果你对那些通常的元字符进行转义，你的正则表达式一样会工作得很好，但是这会降低可读性。在字符集定义中为了将反斜杠“\”作为一个文字字符而非特殊含义的字符，你需要用另一个反斜杠对它进行转义。&lt;&lt;[\\x]&gt;&gt;将会匹配一个反斜杠和一个X。“]^-”都可以用反斜杠进行转义，或者将他们放在一个不可能使用到他们特殊含义的位置。我们推荐后者，因为这样可以增加可读性。比如对于字符“^”，将它放在除了左括号“[”后面的位置，使用的都是文字字符含义而非取反含义。如&lt;&lt;[x^]&gt;&gt;会匹配一个x或^。&lt;&lt;[]x]&gt;&gt;会匹配一个“]”或“x”。&lt;&lt;[-x]&gt;&gt;或&lt;&lt;[x-]&gt;&gt;都会匹配一个“-”或“x”。</p>
<h5>字符集的简写</h5>
<p>因为一些字符集非常常用，所以有一些简写方式。&lt;&lt;\d&gt;&gt;代表&lt;&lt;[0-9]&gt;&gt;;</p>
<p>&lt;&lt;\w&gt;&gt;代表单词字符。这个是随正则表达式实现的不同而有些差异。绝大多数的正则表达式实现的单词字符集都包含了&lt;&lt;A-Za-z0-9_]&gt;&gt;。</p>
<p>&lt;&lt;\s&gt;&gt;代表“白字符”。这个也是和不同的实现有关的。在绝大多数的实现中，都包含了空格符和Tab符，以及回车换行符&lt;&lt;\r\n&gt;&gt;。</p>
<p>字符集的缩写形式可以用在方括号之内或之外。&lt;&lt;\s\d&gt;&gt;匹配一个白字符后面紧跟一个数字。&lt;&lt;[\s\d]&gt;&gt;匹配单个白字符或数字。&lt;&lt;[\da-fA-F]&gt;&gt;将匹配一个十六进制数字。</p>
<h5>取反字符集的简写</h5>
<p>&lt;&lt;[\S]&gt;&gt; = &lt;&lt;[^\s]&gt;&gt;&lt;&lt;[\W]&gt;&gt; = &lt;&lt;[^\w]&gt;&gt;</p>
<p>&lt;&lt;[\D]&gt;&gt; = &lt;&lt;[^\d]&gt;&gt;</p>
<h5>字符集的重复</h5>
<p>如果你用“?*+”操作符来重复一个字符集，你将会重复整个字符集。而不仅是它匹配的那个字符。正则表达式&lt;&lt;[0-9]+&gt;&gt;会匹配837以及222。如果你仅仅想重复被匹配的那个字符，可以用向后引用达到目的。我们以后将讲到向后引用。</p>
<h5>使用?*或+ 进行重复</h5>
<p>?：告诉引擎匹配前导字符0次或一次。事实上是表示前导字符是可选的。+：告诉引擎匹配前导字符1次或多次</p>
<p>*：告诉引擎匹配前导字符0次或多次</p>
<p>&lt;[A-Za-z][A-Za-z0-9]*&gt;匹配没有属性的HTML标签，“&lt;”以及“&gt;”是文字符号。第一个字符集匹配一个字母，第二个字符集匹配一个字母或数字。</p>
<p>我们似乎也可以用&lt;[A-Za-z0-9]+&gt;。但是它会匹配&lt;1&gt;。但是这个正则表达式在你知道你要搜索的字符串不包含类似的无效标签时还是足够有效的。</p>
<h5> 限制性重复</h5>
<p>许多现代的正则表达式实现，都允许你定义对一个字符重复多少次。词法是：{min,max}。min和max都是非负整数。如果逗号有而max被忽略了，则max没有限制。如果逗号和max都被忽略了，则重复min次。因此{0,}和*一样，{1，}和+ 的作用一样。你可以用&lt;&lt;\b[1-9][0-9]{3}\b&gt;&gt;匹配1000~9999之间的数字(“\b”表示单词边界)。&lt;&lt;\b[1-9][0-9]{2,4}\b&gt;&gt;匹配一个在100~99999之间的数字。</p>
<h5>注意贪婪性</h5>
<p>假设你想用一个正则表达式匹配一个HTML标签。你知道输入将会是一个有效的HTML文件，因此正则表达式不需要排除那些无效的标签。所以如果是在两个尖括号之间的内容，就应该是一个HTML标签。许多正则表达式的新手会首先想到用正则表达式&lt;&lt; &lt;.+&gt; &gt;&gt;，他们会很惊讶的发现，对于测试字符串，“This is a &lt;EM&gt;first&lt;/EM&gt; test”，你可能期望会返回&lt;EM&gt;，然后继续进行匹配的时候，返回&lt;/EM&gt;。</p>
<p>但事实是不会。正则表达式将会匹配“&lt;EM&gt;first&lt;/EM&gt;”。很显然这不是我们想要的结果。原因在于“+”是贪婪的。也就是说，“+”会导致正则表达式引擎试图尽可能的重复前导字符。只有当这种重复会引起整个正则表达式匹配失败的情况下，引擎会进行回溯。也就是说，它会放弃最后一次的“重复”，然后处理正则表达式余下的部分。</p>
<p>和“+”类似，“?*”的重复也是贪婪的。</p>
<h5>深入正则表达式引擎内部</h5>
<p>让我们来看看正则引擎如何匹配前面的例子。第一个记号是“&lt;”，这是一个文字符号。第二个符号是“.”，匹配了字符“E”，然后“+”一直可以匹配其余的字符，直到一行的结束。然后到了换行符，匹配失败(“.”不匹配换行符)。于是引擎开始对下一个正则表达式符号进行匹配。也即试图匹配“&gt;”。到目前为止，“&lt;.+”已经匹配了“&lt;EM&gt;first&lt;/EM&gt; test”。引擎会试图将“&gt;”与换行符进行匹配，结果失败了。于是引擎进行回溯。结果是现在“&lt;.+”匹配“&lt;EM&gt;first&lt;/EM&gt; tes”。于是引擎将“&gt;”与“t”进行匹配。显然还是会失败。这个过程继续，直到“&lt;.+”匹配“&lt;EM&gt;first&lt;/EM”，“&gt;”与“&gt;”匹配。于是引擎找到了一个匹配“&lt;EM&gt;first&lt;/EM&gt;”。记住，正则导向的引擎是“急切的”，所以它会急着报告它找到的第一个匹配。而不是继续回溯，即使可能会有更好的匹配，例如“&lt;EM&gt;”。所以我们可以看到，由于“+”的贪婪性，使得正则表达式引擎返回了一个最左边的最长的匹配。</p>
<h5>用懒惰性取代贪婪性</h5>
<p>一个用于修正以上问题的可能方案是用“+”的惰性代替贪婪性。你可以在“+”后面紧跟一个问号“?”来达到这一点。“*”，“{}”和“?”表示的重复也可以用这个方案。因此在上面的例子中我们可以使用“&lt;.+?&gt;”。让我们再来看看正则表达式引擎的处理过程。再一次，正则表达式记号“&lt;”会匹配字符串的第一个“&lt;”。下一个正则记号是“.”。这次是一个懒惰的“+”来重复上一个字符。这告诉正则引擎，尽可能少的重复上一个字符。因此引擎匹配“.”和字符“E”，然后用“&gt;”匹配“M”，结果失败了。引擎会进行回溯，和上一个例子不同，因为是惰性重复，所以引擎是扩展惰性重复而不是减少，于是“&lt;.+”现在被扩展为“&lt;EM”。引擎继续匹配下一个记号“&gt;”。这次得到了一个成功匹配。引擎于是报告“&lt;EM&gt;”是一个成功的匹配。整个过程大致如此。</p>
<h5>惰性扩展的一个替代方案</h5>
<p>我们还有一个更好的替代方案。可以用一个贪婪重复与一个取反字符集：“&lt;[^&gt;]+&gt;”。之所以说这是一个更好的方案在于使用惰性重复时，引擎会在找到一个成功匹配前对每一个字符进行回溯。而使用取反字符集则不需要进行回溯。最后要记住的是，本教程仅仅谈到的是正则导向的引擎。文本导向的引擎是不回溯的。但是同时他们也不支持惰性重复操作。</p>
<h5>使用“.”匹配几乎任意字符</h5>
<p>在正则表达式中，“.”是最常用的符号之一。不幸的是，它也是最容易被误用的符号之一。“.”匹配一个单个的字符而不用关心被匹配的字符是什么。唯一的例外是新行符。在本教程中谈到的引擎，缺省情况下都是不匹配新行符的。因此在缺省情况下，“.”等于是字符集[^\n\r](Window)或[^\n]( Unix)的简写。</p>
<p>这个例外是因为历史的原因。因为早期使用正则表达式的工具是基于行的。它们都是一行一行的读入一个文件，将正则表达式分别应用到每一行上去。在这些工具中，字符串是不包含新行符的。因此“.”也就从不匹配新行符。</p>
<p>现代的工具和语言能够将正则表达式应用到很大的字符串甚至整个文件上去。本教程讨论的所有正则表达式实现都提供一个选项，可以使“.”匹配所有的字符，包括新行符。在RegexBuddy, EditPad Pro或PowerGREP等工具中，你可以简单的选中“点号匹配新行符”。在Perl中，“.”可以匹配新行符的模式被称作“单行模式”。很不幸，这是一个很容易混淆的名词。因为还有所谓“多行模式”。多行模式只影响行首行尾的锚定(anchor)，而单行模式只影响“.”。</p>
<p>其他语言和正则表达式库也采用了Perl的术语定义。当在.NET Framework中使用正则表达式类时，你可以用类似下面的语句来激活单行模式：Regex.Match(“string”,”regex”,RegexOptions.SingleLine).</p>
<h5>保守地使用点号“.”</h5>
<p>点号可以说是最强大的元字符。它允许你偷懒：用一个点号，就能匹配几乎所有的字符。但是问题在于，它也常常会匹配不该匹配的字符。我会以一个简单的例子来说明。让我们看看如何匹配一个具有“mm/dd/yy”格式的日期，但是我们想允许用户来选择分隔符。很快能想到的一个方案是&lt;&lt;\d\d.\d\d.\d\d&gt;&gt;。看上去它能匹配日期“02/12/03”。问题在于02512703也会被认为是一个有效的日期。</p>
<p>&lt;&lt;\d\d[-/.]\d\d[-/.]\d\d&gt;&gt;看上去是一个好一点的解决方案。记住点号在一个字符集里不是元字符。这个方案远不够完善，它会匹配“99/99/99”。而&lt;&lt;[0-1]\d[-/.][0-3]\d[-/.]\d\d&gt;&gt;又更进一步。尽管他也会匹配“19/39/99”。你想要你的正则表达式达到如何完美的程度取决于你想达到什么样的目的。如果你想校验用户输入，则需要尽可能的完美。如果你只是想分析一个已知的源，并且我们知道没有错误的数据，用一个比较好的正则表达式来匹配你想要搜寻的字符就已经足够。</p>
<h5>字符串开始和结束的锚定</h5>
<p>锚定和一般的正则表达式符号不同，它不匹配任何字符。相反，他们匹配的是字符之前或之后的位置。“^”匹配一行字符串第一个字符前的位置。&lt;&lt;^a&gt;&gt;将会匹配字符串“abc”中的a。&lt;&lt;^b&gt;&gt;将不会匹配“abc”中的任何字符。类似的，$匹配字符串中最后一个字符的后面的位置。所以&lt;&lt;c$&gt;&gt;匹配“abc”中的c。</p>
<h5>锚定的应用</h5>
<p>在编程语言中校验用户输入时，使用锚定是非常重要的。如果你想校验用户的输入为整数，用&lt;&lt;^\d+$&gt;&gt;。用户输入中，常常会有多余的前导空格或结束空格。你可以用&lt;&lt;^\s*&gt;&gt;和&lt;&lt;\s*$&gt;&gt;来匹配前导空格或结束空格。</p>
<h5>使用“^”和“$”作为行的开始和结束锚定</h5>
<p>如果你有一个包含了多行的字符串。例如：“first line\n\rsecond line”(其中\n\r表示一个新行符)。常常需要对每行分别处理而不是整个字符串。因此，几乎所有的正则表达式引擎都提供一个选项，可以扩展这两种锚定的含义。“^”可以匹配字串的开始位置(在f之前)，以及每一个新行符的后面位置(在\n\r和s之间)。类似的，$会匹配字串的结束位置(最后一个e之后)，以及每个新行符的前面(在e与\n\r之间)。在.NET中，当你使用如下代码时，将会定义锚定匹配每一个新行符的前面和后面位置：Regex.Match(&#8221;string&#8221;, &#8220;regex&#8221;, RegexOptions.Multiline)</p>
<p>应用：string str = Regex.Replace(Original, &#8220;^&#8221;, &#8220;&gt; &#8220;, RegexOptions.Multiline)&#8211;将会在每行的行首插入“&gt; ”。</p>
<h5>绝对锚定</h5>
<p>&lt;&lt;\A&gt;&gt;只匹配整个字符串的开始位置，&lt;&lt;\Z&gt;&gt;只匹配整个字符串的结束位置。即使你使用了“多行模式”，&lt;&lt;\A&gt;&gt;和&lt;&lt;\Z&gt;&gt;也从不匹配新行符。即使\Z和$只匹配字符串的结束位置，仍然有一个例外的情况。如果字符串以新行符结束，则\Z和$将会匹配新行符前面的位置，而不是整个字符串的最后面。这个“改进”是由Perl引进的，然后被许多的正则表达式实现所遵循，包括Java，.NET等。如果应用&lt;&lt;^[a-z]+$&gt;&gt;到“joe\n”，则匹配结果是“joe”而不是“joe\n”。</p>
<h5>单词边界</h5>
<p>元字符&lt;&lt;\b&gt;&gt;也是一种对位置进行匹配的“锚”。这种匹配是0长度匹配。有4种位置被认为是“单词边界”：</p>
<blockquote><p>1)        在字符串的第一个字符前的位置(如果字符串的第一个字符是一个“单词字符”)</p>
<p>2)        在字符串的最后一个字符后的位置(如果字符串的最后一个字符是一个“单词字符”)</p>
<p>3)        在一个“单词字符”和“非单词字符”之间，其中“非单词字符”紧跟在“单词字符”之后</p>
<p>4)        在一个“非单词字符”和“单词字符”之间，其中“单词字符”紧跟在“非单词字符”后面</p>
</blockquote>
<p>“单词字符”是可以用“\w”匹配的字符，“非单词字符”是可以用“\W”匹配的字符。在大多数的正则表达式实现中，“单词字符”通常包括&lt;&lt;[a-zA-Z0-9_]&gt;&gt;。</p>
<p>例如：&lt;&lt;\b4\b&gt;&gt;能够匹配单个的4而不是一个更大数的一部分。这个正则表达式不会匹配“44”中的4。</p>
<p>换种说法，几乎可以说&lt;&lt;\b&gt;&gt;匹配一个“字母数字序列”的开始和结束的位置。</p>
<p>“单词边界”的取反集为&lt;&lt;\B&gt;&gt;，他要匹配的位置是两个“单词字符”之间或者两个“非单词字符”之间的位置。</p>
<h5> 深入正则表达式引擎内部</h5>
<p>让我们看看把正则表达式&lt;&lt;\bis\b&gt;&gt;应用到字符串“This island is beautiful”。引擎先处理符号&lt;&lt;\b&gt;&gt;。因为\b是0长度 ，所以第一个字符T前面的位置会被考察。因为T是一个“单词字符”，而它前面的字符是一个空字符(void)，所以\b匹配了单词边界。接着&lt;&lt;i&gt;&gt;和第一个字符“T”匹配失败。匹配过程继续进行，直到第五个空格符，和第四个字符“s”之间又匹配了&lt;&lt;\b&gt;&gt;。然而空格符和&lt;&lt;i&gt;&gt;不匹配。继续向后，到了第六个字符“i”，和第五个空格字符之间匹配了&lt;&lt;\b&gt;&gt;，然后&lt;&lt;is&gt;&gt;和第六、第七个字符都匹配了。然而第八个字符和第二个“单词边界”不匹配，所以匹配又失败了。到了第13个字符i，因为和前面一个空格符形成“单词边界”，同时&lt;&lt;is&gt;&gt;和“is”匹配。引擎接着尝试匹配第二个&lt;&lt;\b&gt;&gt;。因为第15个空格符和“s”形成单词边界，所以匹配成功。引擎“急着”返回成功匹配的结果。</p>
<h5>选择符</h5>
<p>正则表达式中“|”表示选择。你可以用选择符匹配多个可能的正则表达式中的一个。如果你想搜索文字“cat”或“dog”，你可以用&lt;&lt;cat|dog&gt;&gt;。如果你想有更多的选择，你只要扩展列表&lt;&lt;cat|dog|mouse|fish&gt;&gt;。</p>
<p>选择符在正则表达式中具有最低的优先级，也就是说，它告诉引擎要么匹配选择符左边的所有表达式，要么匹配右边的所有表达式。你也可以用圆括号来限制选择符的作用范围。如&lt;&lt;\b(cat|dog)\b&gt;&gt;，这样告诉正则引擎把(cat|dog)当成一个正则表达式单位来处理。</p>
<h5>注意正则引擎的“急于表功”性 </h5>
<p>正则引擎是急切的，当它找到一个有效的匹配时，它会停止搜索。因此在一定条件下，选择符两边的表达式的顺序对结果会有影响。假设你想用正则表达式搜索一个编程语言的函数列表：Get，GetValue，Set或SetValue。一个明显的解决方案是&lt;&lt;Get|GetValue|Set|SetValue&gt;&gt;。让我们看看当搜索SetValue时的结果。</p>
<p>因为&lt;&lt;Get&gt;&gt;和&lt;&lt;GetValue&gt;&gt;都失败了，而&lt;&lt;Set&gt;&gt;匹配成功。因为正则导向的引擎都是“急切”的，所以它会返回第一个成功的匹配，就是“Set”，而不去继续搜索是否有其他更好的匹配。</p>
<p>和我们期望的相反，正则表达式并没有匹配整个字符串。有几种可能的解决办法。一是考虑到正则引擎的“急切”性，改变选项的顺序，例如我们使用&lt;&lt;GetValue|Get|SetValue|Set&gt;&gt;，这样我们就可以优先搜索最长的匹配。我们也可以把四个选项结合起来成两个选项：&lt;&lt;Get(Value)?|Set(Value)?&gt;&gt;。因为问号重复符是贪婪的，所以SetValue总会在Set之前被匹配。</p>
<p>一个更好的方案是使用单词边界：&lt;&lt;\b(Get|GetValue|Set|SetValue)\b&gt;&gt;或&lt;&lt;\b(Get(Value)?|Set(Value)?\b&gt;&gt;。更进一步，既然所有的选择都有相同的结尾，我们可以把正则表达式优化为&lt;&lt;\b(Get|Set)(Value)?\b&gt;&gt;。</p>
<h5>组与向后引用</h5>
<p>把正则表达式的一部分放在圆括号内，你可以将它们形成组。然后你可以对整个组使用一些正则操作，例如重复操作符。要注意的是，只有圆括号“()”才能用于形成组。“[]”用于定义字符集。“{}”用于定义重复操作。</p>
<p>当用“()”定义了一个正则表达式组后，正则引擎则会把被匹配的组按照顺序编号，存入缓存。当对被匹配的组进行向后引用的时候，可以用“\数字”的方式进行引用。&lt;&lt;\1&gt;&gt;引用第一个匹配的后向引用组，&lt;&lt;\2&gt;&gt;引用第二个组，以此类推，&lt;&lt;\n&gt;&gt;引用第n个组。而&lt;&lt;\0&gt;&gt;则引用整个被匹配的正则表达式本身。我们看一个例子。</p>
<p>假设你想匹配一个HTML标签的开始标签和结束标签，以及标签中间的文本。比如&lt;B&gt;This is a test&lt;/B&gt;，我们要匹配&lt;B&gt;和&lt;/B&gt;以及中间的文字。我们可以用如下正则表达式：“&lt;([A-Z][A-Z0-9]*)[^&gt;]*&gt;.*?&lt;/\1&gt;”</p>
<p>首先，“&lt;”将会匹配“&lt;B&gt;”的第一个字符“&lt;”。然后[A-Z]匹配B，[A-Z0-9]*将会匹配0到多次字母数字，后面紧接着0到多个非“&gt;”的字符。最后正则表达式的“&gt;”将会匹配“&lt;B&gt;”的“&gt;”。接下来正则引擎将对结束标签之前的字符进行惰性匹配，直到遇到一个“&lt;/”符号。然后正则表达式中的“\1”表示对前面匹配的组“([A-Z][A-Z0-9]*)”进行引用，在本例中，被引用的是标签名“B”。所以需要被匹配的结尾标签为“&lt;/B&gt;”</p>
<p>你可以对相同的后向引用组进行多次引用，&lt;&lt;([a-c])x\1x\1&gt;&gt;将匹配“axaxa”、“bxbxb”以及“cxcxc”。如果用数字形式引用的组没有有效的匹配，则引用到的内容简单的为空。</p>
<p>一个后向引用不能用于它自身。&lt;&lt;([abc]\1)&gt;&gt;是错误的。因此你不能将&lt;&lt;\0&gt;&gt;用于一个正则表达式匹配本身，它只能用于替换操作中。</p>
<p>后向引用不能用于字符集内部。&lt;&lt;(a)[\1b]&gt;&gt;中的&lt;&lt;\1&gt;&gt;并不表示后向引用。在字符集内部，&lt;&lt;\1&gt;&gt;可以被解释为八进制形式的转码。</p>
<p>向后引用会降低引擎的速度，因为它需要存储匹配的组。如果你不需要向后引用，你可以告诉引擎对某个组不存储。例如：&lt;&lt;Get(?:Value)&gt;&gt;。其中“(”后面紧跟的“?:”会告诉引擎对于组(Value)，不存储匹配的值以供后向引用。</p>
<h5>重复操作与后向引用 </h5>
<p>当对组使用重复操作符时，缓存里后向引用内容会被不断刷新，只保留最后匹配的内容。例如：&lt;&lt;([abc]+)=\1&gt;&gt;将匹配“cab=cab”，但是&lt;&lt;([abc])+=\1&gt;&gt;却不会。因为([abc])第一次匹配“c”时，“\1”代表“c”；然后([abc])会继续匹配“a”和“b”。最后“\1”代表“b”，所以它会匹配“cab=b”。应用：检查重复单词&#8211;当编辑文字时，很容易就会输入重复单词，例如“the the”。使用&lt;&lt;\b(\w+)\s+\1\b&gt;&gt;可以检测到这些重复单词。要删除第二个单词，只要简单的利用替换功能替换掉“\1”就可以了。</p>
<h5>组的命名和引用</h5>
<p>在PHP，Python中，可以用&lt;&lt;(?P&lt;name&gt;group)&gt;&gt;来对组进行命名。在本例中，词法?P&lt;name&gt;就是对组(group)进行了命名。其中name是你对组的起的名字。你可以用(?P=name)进行引用。</p>
<h5>.NET的命名组</h5>
<p>.NET framework也支持命名组。不幸的是，微软的程序员们决定发明他们自己的语法，而不是沿用Perl、Python的规则。目前为止，还没有任何其他的正则表达式实现支持微软发明的语法。下面是.NET中的例子：</p>
<p>(?&lt;first&gt;group)(?’second’group)</p>
<p>正如你所看到的，.NET提供两种词法来创建命名组：一是用尖括号“&lt;&gt;”，或者用单引号“’’”。尖括号在字符串中使用更方便，单引号在ASP代码中更有用，因为ASP代码中“&lt;&gt;”被用作HTML标签。</p>
<p>要引用一个命名组，使用\k&lt;name&gt;或\k’name’.</p>
<p>当进行搜索替换时，你可以用“${name}”来引用一个命名组。</p>
<h5>正则表达式的匹配模式</h5>
<p>本教程所讨论的正则表达式引擎都支持三种匹配模式：&lt;&lt;/i&gt;&gt;使正则表达式对大小写不敏感，</p>
<p>&lt;&lt;/s&gt;&gt;开启“单行模式”，即点号“.”匹配新行符</p>
<p>&lt;&lt;/m&gt;&gt;开启“多行模式”，即“^”和“$”匹配新行符的前面和后面的位置。</p>
<h5>在正则表达式内部打开或关闭模式 </h5>
<p>如果你在正则表达式内部插入修饰符(?ism)，则该修饰符只对其右边的正则表达式起作用。(?-i)是关闭大小写不敏感。你可以很快的进行测试。&lt;&lt;(?i)te(?-i)st&gt;&gt;应该匹配TEst，但是不能匹配teST或TEST.</p>
<h5>原子组与防止回溯</h5>
<p>在一些特殊情况下，因为回溯会使得引擎的效率极其低下。让我们看一个例子：要匹配这样的字串，字串中的每个字段间用逗号做分隔符，第12个字段由P开头。</p>
<p>我们容易想到这样的正则表达式&lt;&lt;^(.*?,){11}P&gt;&gt;。这个正则表达式在正常情况下工作的很好。但是在极端情况下，如果第12个字段不是由P开头，则会发生灾难性的回溯。如要搜索的字串为“1,2,3,4,5,6,7,8,9,10,11,12,13”。首先，正则表达式一直成功匹配直到第12个字符。这时，前面的正则表达式消耗的字串为“1,2,3,4,5,6,7,8,9,10,11,”，到了下一个字符，&lt;&lt;P&gt;&gt;并不匹配“12”。所以引擎进行回溯，这时正则表达式消耗的字串为“1,2,3,4,5,6,7,8,9,10,11”。继续下一次匹配过程，下一个正则符号为点号&lt;&lt;.&gt;&gt;，可以匹配下一个逗号“,”。然而&lt;&lt;，&gt;&gt;并不匹配字符“12”中的“1”。匹配失败，继续回溯。大家可以想象，这样的回溯组合是个非常大的数量。因此可能会造成引擎崩溃。</p>
<p>用于阻止这样巨大的回溯有几种方案：</p>
<p>一种简单的方案是尽可能的使匹配精确。用取反字符集代替点号。例如我们用如下正则表达式&lt;&lt;^([^,\r\n]*,){11}P&gt;&gt;，这样可以使失败回溯的次数下降到11次。</p>
<p>另一种方案是使用原子组。</p>
<p>原子组的目的是使正则引擎失败的更快一点。因此可以有效的阻止海量回溯。原子组的语法是&lt;&lt;(?&gt;正则表达式)&gt;&gt;。位于(?&gt;)之间的所有正则表达式都会被认为是一个单一的正则符号。一旦匹配失败，引擎将会回溯到原子组前面的正则表达式部分。前面的例子用原子组可以表达成&lt;&lt;^(?&gt;(.*?,){11})P&gt;&gt;。一旦第十二个字段匹配失败，引擎回溯到原子组前面的&lt;&lt;^&gt;&gt;。</p>
<h5>向前查看与向后查看</h5>
<p>Perl 5 引入了两个强大的正则语法：“向前查看”和“向后查看”。他们也被称作“零长度断言”。他们和锚定一样都是零长度的（所谓零长度即指该正则表达式不消耗被匹配的字符串）。不同之处在于“前后查看”会实际匹配字符，只是他们会抛弃匹配只返回匹配结果：匹配或不匹配。这就是为什么他们被称作“断言”。他们并不实际消耗字符串中的字符，而只是断言一个匹配是否可能。几乎本文讨论的所有正则表达式的实现都支持“向前向后查看”。唯一的一个例外是Javascript只支持向前查看。</p>
<h5>肯定和否定式的向前查看</h5>
<p>如我们前面提过的一个例子：要查找一个q，后面没有紧跟一个u。也就是说，要么q后面没有字符，要么后面的字符不是u。采用否定式向前查看后的一个解决方案为&lt;&lt;q(?!u)&gt;&gt;。否定式向前查看的语法是&lt;&lt;(?!查看的内容)&gt;&gt;。肯定式向前查看和否定式向前查看很类似：&lt;&lt;(?=查看的内容)&gt;&gt;。</p>
<p>如果在“查看的内容”部分有组，也会产生一个向后引用。但是向前查看本身并不会产生向后引用，也不会被计入向后引用的编号中。这是因为向前查看本身是会被抛弃掉的，只保留匹配与否的判断结果。如果你想保留匹配的结果作为向后引用，你可以用&lt;&lt;(?=(regex))&gt;&gt;来产生一个向后引用。</p>
<h5>肯定和否定式的先后查看</h5>
<p>向后查看和向前查看有相同的效果，只是方向相反否定式向后查看的语法是：&lt;&lt;(?&lt;!查看内容)&gt;&gt;</p>
<p>肯定式向后查看的语法是：&lt;&lt;(?&lt;=查看内容)&gt;&gt;</p>
<p>我们可以看到，和向前查看相比，多了一个表示方向的左尖括号。</p>
<p>例：&lt;&lt;(?&lt;!a)b&gt;&gt;将会匹配一个没有“a”作前导字符的“b”。</p>
<p>值得注意的是：向前查看从当前字符串位置开始对“查看”正则表达式进行匹配；向后查看则从当前字符串位置开始先后回溯一个字符，然后再开始对“查看”正则表达式进行匹配。</p>
<h5>深入正则表达式引擎内部</h5>
<p>让我们看一个简单例子。把正则表达式&lt;&lt;q(?!u)&gt;&gt;应用到字符串“Iraq”。正则表达式的第一个符号是&lt;&lt;q&gt;&gt;。正如我们知道的，引擎在匹配&lt;&lt;q&gt;&gt;以前会扫过整个字符串。当第四个字符“q”被匹配后，“q”后面是空字符(void)。而下一个正则符号是向前查看。引擎注意到已经进入了一个向前查看正则表达式部分。下一个正则符号是&lt;&lt;u&gt;&gt;，和空字符不匹配，从而导致向前查看里的正则表达式匹配失败。因为是一个否定式的向前查看，意味着整个向前查看结果是成功的。于是匹配结果“q”被返回了。</p>
<p>我们在把相同的正则表达式应用到“quit”。&lt;&lt;q&gt;&gt;匹配了“q”。下一个正则符号是向前查看部分的&lt;&lt;u&gt;&gt;，它匹配了字符串中的第二个字符“i”。引擎继续走到下个字符“i”。然而引擎这时注意到向前查看部分已经处理完了，并且向前查看已经成功。于是引擎抛弃被匹配的字符串部分，这将导致引擎回退到字符“u”。</p>
<p>因为向前查看是否定式的，意味着查看部分的成功匹配导致了整个向前查看的失败，因此引擎不得不进行回溯。最后因为再没有其他的“q”和&lt;&lt;q&gt;&gt;匹配，所以整个匹配失败了。</p>
<p>为了确保你能清楚地理解向前查看的实现，让我们把&lt;&lt;q(?=u)i&gt;&gt;应用到“quit”。&lt;&lt;q&gt;&gt;首先匹配“q”。然后向前查看成功匹配“u”，匹配的部分被抛弃，只返回可以匹配的判断结果。引擎从字符“i”回退到“u”。由于向前查看成功了，引擎继续处理下一个正则符号&lt;&lt;i&gt;&gt;。结果发现&lt;&lt;i&gt;&gt;和“u”不匹配。因此匹配失败了。由于后面没有其他的“q”，整个正则表达式的匹配失败了。</p>
<h5>更进一步理解正则表达式引擎内部机制</h5>
<p>让我们把&lt;&lt;(?&lt;=a)b&gt;&gt;应用到“thingamabob”。引擎开始处理向后查看部分的正则符号和字符串中的第一个字符。在这个例子中，向后查看告诉正则表达式引擎回退一个字符，然后查看是否有一个“a”被匹配。因为在“t”前面没有字符，所以引擎不能回退。因此向后查看失败了。引擎继续走到下一个字符“h”。再一次，引擎暂时回退一个字符并检查是否有个“a”被匹配。结果发现了一个“t”。向后查看又失败了。向后查看继续失败，直到正则表达式到达了字符串中的“m”，于是肯定式的向后查看被匹配了。因为它是零长度的，字符串的当前位置仍然是“m”。下一个正则符号是&lt;&lt;b&gt;&gt;，和“m”匹配失败。下一个字符是字符串中的第二个“a”。引擎向后暂时回退一个字符，并且发现&lt;&lt;a&gt;&gt;不匹配“m”。</p>
<p>在下一个字符是字符串中的第一个“b”。引擎暂时性的向后退一个字符发现向后查看被满足了，同时&lt;&lt;b&gt;&gt;匹配了“b”。因此整个正则表达式被匹配了。作为结果，正则表达式返回字符串中的第一个“b”。</p>
<h5>向前向后查看的应用</h5>
<p>我们来看这样一个例子：查找一个具有6位字符的，含有“cat”的单词。首先，我们可以不用向前向后查看来解决问题，例如：</p>
<p>&lt;&lt; cat\w{3}|\wcat\w{2}|\w{2}cat\w|\w{3}cat&gt;&gt;</p>
<p>足够简单吧！但是当需求变成查找一个具有6-12位字符，含有“cat”，“dog”或“mouse”的单词时，这种方法就变得有些笨拙了。</p>
<p>我们来看看使用向前查看的方案。在这个例子中，我们有两个基本需求要满足：一是我们需要一个6位的字符，二是单词含有“cat”。</p>
<p>满足第一个需求的正则表达式为&lt;&lt;\b\w{6}\b&gt;&gt;。满足第二个需求的正则表达式为&lt;&lt;\b\w*cat\w*\b&gt;&gt;。</p>
<p>把两者结合起来，我们可以得到如下的正则表达式：</p>
<p>&lt;&lt;(?=\b\w{6}\b)\b\w*cat\w*\b&gt;&gt;</p>
<p>具体的匹配过程留给读者。但是要注意的一点是，向前查看是不消耗字符的，因此当判断单词满足具有6个字符的条件后，引擎会从开始判断前的位置继续对后面的正则表达式进行匹配。</p>
<p>最后作些优化，可以得到下面的正则表达式：</p>
<p>&lt;&lt;\b(?=\w{6}\b)\w{0,3}cat\w*&gt;&gt;</p>
<h5>正则表达式中的条件测试</h5>
<p>条件测试的语法为&lt;&lt;(?ifthen|else)&gt;&gt;。“if”部分可以是向前向后查看表达式。如果用向前查看，则语法变为：&lt;&lt;(?(?=regex)then|else)&gt;&gt;，其中else部分是可选的。如果if部分为true，则正则引擎会试图匹配then部分，否则引擎会试图匹配else部分。</p>
<p>需要记住的是，向前先后查看并不实际消耗任何字符，因此后面的then与else部分的匹配时从if测试前的部分开始进行尝试。</p>
<h5>为正则表达式添加注释</h5>
<p>在正则表达式中添加注释的语法是：&lt;&lt;(?#comment)&gt;&gt;例：为用于匹配有效日期的正则表达式添加注释：</p>
<p>(?#year)(19|20)\d\d[- /.](?#month)(0[1-9]|1[012])[- /.](?#day)(0[1-9]|[12][0-9]|3[01])</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Zqm1bmpFqe2JbPKoUw_RSVGO9A0/0/da"><img src="http://feedads.g.doubleclick.net/~a/Zqm1bmpFqe2JbPKoUw_RSVGO9A0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Zqm1bmpFqe2JbPKoUw_RSVGO9A0/1/da"><img src="http://feedads.g.doubleclick.net/~a/Zqm1bmpFqe2JbPKoUw_RSVGO9A0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gphEN54UWI0:xbtP9flecfA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gphEN54UWI0:xbtP9flecfA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=gphEN54UWI0:xbtP9flecfA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gphEN54UWI0:xbtP9flecfA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gphEN54UWI0:xbtP9flecfA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=gphEN54UWI0:xbtP9flecfA:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/gphEN54UWI0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/15/regex-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/15/regex-2/</feedburner:origLink></item>
		<item>
		<title>PHP字符串操作入门</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/NpBTPS7m80M/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/10/php-string/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 04:20:52 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=237</guid>
		<description><![CDATA[无论哪种语言，字符串操作都是一个重要的基础，往往是简单而重要。正像人说话一样，一般有形体（图形界面），有语言（print 字符串？），显然字符串能解释更多的东西。PHP提供了大量的字符串操作函数，功能强大，使用也比较简单，详细请参看 http://cn2.php.net/manual/zh/ref.strings.php . 以下将简单的讲述它的功能和特性。
h5>弱类型 
PHP是弱类型语言，所以其它类型的数据一般可以直接应用于字符串操作函数里，而自动转换成字符串类型，进行处理，如: 
echo&#160;substr(&#34;1234567&#34;,&#160;1,&#160;3);&#160; 
和 
echo&#160;substr(123456,1,&#160;3);&#160; 
是一样的 
定义
一般用双引号或单引号标识一个字符串。比如 
$str&#160;=&#160;&#34;i&#160;love&#160;u&#34;;&#160;
$str&#160;=&#160;'i&#160;love&#160;u';&#160; 
它者两者是有一些区别的。后者将一切单引号的内容都会当作字符处理；前者则不然。比如 
$test&#160;=&#160;&#34;iwind&#34;;&#160;
$str&#160;=&#160;&#34;i&#160;love&#160;$test&#34;;&#160;
$str1&#160;=&#160;'i&#160;love&#160;$test';&#160;
echo&#160;$str;&#160;//将得到&#160;i&#160;love&#160;iwind&#160;
echo&#160;$str1;&#160;//将得到&#160;i&#160;love&#160;$test&#160; 
同样的以下两个例子的行为也不一样的: 
echo&#160;&#34;i&#160;love&#160;test&#34;;&#160;//&#160;将得到&#160;i&#160;love&#160;est,已经将t视为转义&#160;
echo&#160;'i&#160;love&#160;test';&#160;//&#160;将得到&#160;i&#160;love&#160;test&#160; 
从而可以简单认为双引号里的内容是经过&#8220;解释&#8221;过的，单引号的是&#8220;所见即所得&#8221;的。显而易见，双引号形式的更为灵活一些，当然单引号会适用于一些特殊的场合，这里就不作阐述了。 
输出
PHP里的输出最常用的是echo,print.两者都不是真正的函数，而是语言构造，所以调用时不必用双括号（比如echo(&#34;test&#34;);print(&#34;test&#34;)).在输出的时候两者都可以实现赋值： 
echo&#160;$str=&#34;test&#34;;&#160;//一方面输出test,一方面把&#34;test&#34;赋给字符串变量&#160;$str&#160;
print&#160;$str=&#34;test&#34;;&#160; 
两者除了名字不一样外，还是有其它区别的。print具有返回值，一直返回1,而echo没有，所以echo比print要快一些: 
$return&#160;=&#160;print&#160;&#34;test&#34;;&#160;
echo&#160;$return;&#160;//&#160;输出1&#160; 
也正因为这个原因，print能应用于复合语句中，而echo不能: 
isset($str)&#160;or&#160;print&#160;&#34;str&#160;变量未定义&#34;;&#160;//&#160;将输出&#34;str&#160;变量未定义&#34;&#160;
isset($str)&#160;or&#160;echo&#160;&#34;str&#160;变量未定义&#34;;//&#160;将提示分析错误&#160; 
echo一次可输出多个字符串，而print则不可以： 
echo&#160;&#34;i&#160;&#34;,&#34;love&#160;&#34;,&#34;iwind&#34;;&#160;//&#160;将输出&#160;&#34;i&#160;love&#160;iwind&#34;&#160;
print&#160;&#34;i&#160;&#34;,&#34;love&#160;&#34;,&#34;iwind&#34;;&#160;//&#160;将提示错误&#160; 
echo,print还可以输出被称作&#8220;文档句法&#8221;的字符串，句法如: 
echo&#160;&#60;&#60;&#60;&#160;标签名称&#160;
...&#160;
字符串内容&#160;
...&#160;
标签名称;&#160; 
比如 
echo&#160;&#60;&#60;&#60;&#160;test&#160;
i&#160;love&#160;iwind&#160;
test;&#160; 
要注意的是语句开始和结束的两个标签名称是一样的，且后一个标签名称前不能有空白，即要顶格写。文档句法输出的内容识别变量名称和常用符号,大致形同双引号的作用。 
输出echo,print外，PHP还提供了一些格式化字符串的函数,比如printf,sprintf,vprintf,vsprintf,在这里不作详解。 
连接
两个以上的字符串连接用&#34;.&#34;操作符，依字符串的顺序形成新的字符串。 
$str&#160;=&#160;&#34;i&#160;&#34;&#160;.&#160;&#34;love&#160;&#34;&#160;.&#160;&#34;iwind&#34;;&#160;
这里的$str&#160;就是&#160;&#34;i&#160;love&#160;iwind&#34;;字符串。当然，还可以使用&#160;.=&#160;操作符:&#160;
$str&#160;=&#160;&#34;&#34;;&#160;//&#160;初始化&#160;
$str&#160;.=&#160;&#34;i&#160;love&#160;iwind&#34;;&#160; 
这里用到了初始化，是因为未定义变量在使用时会产生一个notice错误，&#34;&#34;或者null可以简单地代表空字符串。 
长度
PHP提供strlen函数来计算字符串的长度: 
$str&#160;=&#160;&#34;test&#34;;&#160;
echo&#160;strlen($str);&#160;//&#160;将输出&#160;4&#160; 
有点奇怪的是strlen将中日等汉字以及全角字符都当作两个或四个长度计算。好在mbstring或icon两个函数可以帮助解决这个问题，比如: 
$len&#160;=&#160;iconv_strlen($str,&#160;&#34;GBK&#34;);&#160;
$len&#160;=&#160;mb_strlen($str,&#160;&#34;GBK&#34;);&#160; 
注:mbstring模块提供了大量的对含有多字节字符的字符串的处理函数，推荐多加应用，由于这篇文章讲的是字符串入门，所以不打算详细解说。 
分隔与连接
PHP允许你把一个字符串按照一个分隔符进行分隔成一个数组，或者将一个数组组合成一个字符串。看下面的例子： 
$str&#160;=&#160;&#34;i&#160;love&#160;iwind&#34;;&#160;
$array&#160;=&#160;explode(&#34;&#160;&#34;,&#160;$str);&#160; 
上面的explode函数，就把$str字符串按空格字符进行分隔，结果返回一个数组 $array:array(&#34;i&#34;, &#34;love&#34;, &#34;iwind&#34;).与explode函数有类似功能的有：preg_split(), spliti(), split()等函数。 
与此相反的，implode和join则能把一个数组结合成一个字符串，他们是具有完全相同功能的函数。 
$array&#160;=&#160;array(&#34;i&#34;,&#160;&#34;love&#34;,&#160;&#34;iwind&#34;);&#160;
$str&#160;=&#160;implode(&#34;&#160;&#34;,&#160;$array);&#160;
例中的implode函数将数组$array的每个元素用空格字符进行连接，返回一个字符串&#160;$str：&#160;&#34;i&#160;love&#160;iwind&#34;.&#160; 
裁剪
一个字符串首和尾，可能不是你想要的部分，就可以用trim,rtrim,ltrim等函数,分别去除一个字符串两端空格，一个字符串尾部空格，一个字符串首部空格。 
echo&#160;trim(&#34;&#160;i&#160;love&#160;iwind&#160;&#34;);&#160;//&#160;将得到&#160;&#34;i&#160;love&#160;iwind&#34;&#160;
echo&#160;rtrim(&#34;&#160;i&#160;love&#160;iwind&#160;&#34;);&#160;//&#160;将得到&#160;&#34;&#160;i&#160;love&#160;iwind&#34;&#160;
echo&#160;ltrim(&#34;&#160;i&#160;love&#160;iwind&#160;&#34;);&#160;//&#160;将得到&#160;&#34;i&#160;love&#160;iwind&#160;&#34;&#160; 
其实这三个参数不仅可以去除字符串首尾的空格，还可以去除它们的第二个参数指定的字符，如: 
echo&#160;trim(&#34;,1,2,3,4,&#34;,&#160;&#34;,&#34;);&#160;//&#160;将得到&#160;1,2,3,4&#160;两端的&#34;,&#34;号被裁掉了。&#160; 
有时还会看到有人使用chop这个函数，其实它是rtrim的同义函数。 
大小写
对于英文字母来说，可以用strtoupper,strtolower将其转变成大写或小写。 [...]]]></description>
			<content:encoded><![CDATA[<p>无论哪种语言，字符串操作都是一个重要的基础，往往是简单而重要。正像人说话一样，一般有形体（图形界面），有语言（print 字符串？），显然字符串能解释更多的东西。PHP提供了大量的字符串操作函数，功能强大，使用也比较简单，详细请参看 http://cn2.php.net/manual/zh/ref.strings.php . 以下将简单的讲述它的功能和特性。<br />
<br />
<h5>弱类型 </h5>
<p>PHP是弱类型语言，所以其它类型的数据一般可以直接应用于字符串操作函数里，而自动转换成字符串类型，进行处理，如: </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">substr</font><font color="#006600">(</font><font color="#cc0000">&quot;1234567&quot;</font><font color="#006600">,&nbsp;</font><font color="#0000cc">1</font><font color="#006600">,&nbsp;</font><font color="#0000cc">3</font><font color="#006600">);&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>和 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">substr</font><font color="#006600">(</font><font color="#0000cc">123456</font><font color="#006600">,</font><font color="#0000cc">1</font><font color="#006600">,&nbsp;</font><font color="#0000cc">3</font><font color="#006600">);&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>是一样的 </p>
<h5>定义</h5>
<p>一般用双引号或单引号标识一个字符串。比如 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;u&quot;</font><font color="#006600">;&nbsp;<br />
</font><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">'i&nbsp;love&nbsp;u'</font><font color="#006600">;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>它者两者是有一些区别的。后者将一切单引号的内容都会当作字符处理；前者则不然。比如 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$test&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">;&nbsp;<br />
</font><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;$test&quot;</font><font color="#006600">;&nbsp;<br />
</font><font color="#0000cc">$str1&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">'i&nbsp;love&nbsp;$test'</font><font color="#006600">;&nbsp;<br />
echo&nbsp;</font><font color="#0000cc">$str</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//将得到&nbsp;i&nbsp;love&nbsp;iwind&nbsp;<br />
</font><font color="#006600">echo&nbsp;</font><font color="#0000cc">$str1</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//将得到&nbsp;i&nbsp;love&nbsp;$test&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>同样的以下两个例子的行为也不一样的: </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;test&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;将得到&nbsp;i&nbsp;love&nbsp;est,已经将t视为转义&nbsp;<br />
</font><font color="#006600">echo&nbsp;</font><font color="#cc0000">'i&nbsp;love&nbsp;test'</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;将得到&nbsp;i&nbsp;love&nbsp;test&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>从而可以简单认为双引号里的内容是经过&ldquo;解释&rdquo;过的，单引号的是&ldquo;所见即所得&rdquo;的。显而易见，双引号形式的更为灵活一些，当然单引号会适用于一些特殊的场合，这里就不作阐述了。 </p>
<h5>输出</h5>
<p>PHP里的输出最常用的是echo,print.两者都不是真正的函数，而是语言构造，所以调用时不必用双括号（比如echo(&quot;test&quot;);print(&quot;test&quot;)).在输出的时候两者都可以实现赋值： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">$str</font><font color="#006600">=</font><font color="#cc0000">&quot;test&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//一方面输出test,一方面把&quot;test&quot;赋给字符串变量&nbsp;$str&nbsp;<br />
</font><font color="#006600">print&nbsp;</font><font color="#0000cc">$str</font><font color="#006600">=</font><font color="#cc0000">&quot;test&quot;</font><font color="#006600">;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>两者除了名字不一样外，还是有其它区别的。print具有返回值，一直返回1,而echo没有，所以echo比print要快一些: </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$return&nbsp;</font><font color="#006600">=&nbsp;print&nbsp;</font><font color="#cc0000">&quot;test&quot;</font><font color="#006600">;&nbsp;<br />
echo&nbsp;</font><font color="#0000cc">$return</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;输出1&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>也正因为这个原因，print能应用于复合语句中，而echo不能: </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">isset(</font><font color="#0000cc">$str</font><font color="#006600">)&nbsp;or&nbsp;print&nbsp;</font><font color="#cc0000">&quot;str&nbsp;变量未定义&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;将输出&quot;str&nbsp;变量未定义&quot;&nbsp;<br />
</font><font color="#006600">isset(</font><font color="#0000cc">$str</font><font color="#006600">)&nbsp;or&nbsp;echo&nbsp;</font><font color="#cc0000">&quot;str&nbsp;变量未定义&quot;</font><font color="#006600">;</font><font color="#ff9900">//&nbsp;将提示分析错误&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>echo一次可输出多个字符串，而print则不可以： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#cc0000">&quot;i&nbsp;&quot;</font><font color="#006600">,</font><font color="#cc0000">&quot;love&nbsp;&quot;</font><font color="#006600">,</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;将输出&nbsp;&quot;i&nbsp;love&nbsp;iwind&quot;&nbsp;<br />
</font><font color="#006600">print&nbsp;</font><font color="#cc0000">&quot;i&nbsp;&quot;</font><font color="#006600">,</font><font color="#cc0000">&quot;love&nbsp;&quot;</font><font color="#006600">,</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;将提示错误&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>echo,print还可以输出被称作&ldquo;文档句法&rdquo;的字符串，句法如: </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;&lt;&lt;&lt;&nbsp;</font><font color="#0000cc">标签名称&nbsp;<br />
</font><font color="#006600">...&nbsp;<br />
</font><font color="#0000cc">字符串内容&nbsp;<br />
</font><font color="#006600">...&nbsp;<br />
</font><font color="#0000cc">标签名称</font><font color="#006600">;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>比如 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;&lt;&lt;&lt;&nbsp;</font><font color="#0000cc">test&nbsp;<br />
i&nbsp;love&nbsp;iwind&nbsp;<br />
test</font><font color="#006600">;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>要注意的是语句开始和结束的两个标签名称是一样的，且后一个标签名称前不能有空白，即要顶格写。文档句法输出的内容识别变量名称和常用符号,大致形同双引号的作用。 </p>
<p>输出echo,print外，PHP还提供了一些格式化字符串的函数,比如printf,sprintf,vprintf,vsprintf,在这里不作详解。 </p>
<h5>连接</h5>
<p>两个以上的字符串连接用&quot;.&quot;操作符，依字符串的顺序形成新的字符串。 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;i&nbsp;&quot;&nbsp;</font><font color="#006600">.&nbsp;</font><font color="#cc0000">&quot;love&nbsp;&quot;&nbsp;</font><font color="#006600">.&nbsp;</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">;&nbsp;<br />
</font><font color="#0000cc">这里的$str&nbsp;就是&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;iwind&quot;</font><font color="#006600">;</font><font color="#0000cc">字符串。当然，还可以使用&nbsp;</font><font color="#006600">.=&nbsp;</font><font color="#0000cc">操作符</font><font color="#006600">:&nbsp;<br />
</font><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;初始化&nbsp;<br />
</font><font color="#0000cc">$str&nbsp;</font><font color="#006600">.=&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;iwind&quot;</font><font color="#006600">;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>这里用到了初始化，是因为未定义变量在使用时会产生一个notice错误，&quot;&quot;或者null可以简单地代表空字符串。 </p>
<h5>长度</h5>
<p>PHP提供strlen函数来计算字符串的长度: </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;test&quot;</font><font color="#006600">;&nbsp;<br />
echo&nbsp;</font><font color="#0000cc">strlen</font><font color="#006600">(</font><font color="#0000cc">$str</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将输出&nbsp;4&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>有点奇怪的是strlen将中日等汉字以及全角字符都当作两个或四个长度计算。好在mbstring或icon两个函数可以帮助解决这个问题，比如: </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$len&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#0000cc">iconv_strlen</font><font color="#006600">(</font><font color="#0000cc">$str</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;GBK&quot;</font><font color="#006600">);&nbsp;<br />
</font><font color="#0000cc">$len&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#0000cc">mb_strlen</font><font color="#006600">(</font><font color="#0000cc">$str</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;GBK&quot;</font><font color="#006600">);&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>注:mbstring模块提供了大量的对含有多字节字符的字符串的处理函数，推荐多加应用，由于这篇文章讲的是字符串入门，所以不打算详细解说。 </p>
<h5>分隔与连接</h5>
<p>PHP允许你把一个字符串按照一个分隔符进行分隔成一个数组，或者将一个数组组合成一个字符串。看下面的例子： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;iwind&quot;</font><font color="#006600">;&nbsp;<br />
</font><font color="#0000cc">$array&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#0000cc">explode</font><font color="#006600">(</font><font color="#cc0000">&quot;&nbsp;&quot;</font><font color="#006600">,&nbsp;</font><font color="#0000cc">$str</font><font color="#006600">);&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>上面的explode函数，就把$str字符串按空格字符进行分隔，结果返回一个数组 $array:array(&quot;i&quot;, &quot;love&quot;, &quot;iwind&quot;).与explode函数有类似功能的有：preg_split(), spliti(), split()等函数。 </p>
<p>与此相反的，implode和join则能把一个数组结合成一个字符串，他们是具有完全相同功能的函数。 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$array&nbsp;</font><font color="#006600">=&nbsp;array(</font><font color="#cc0000">&quot;i&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;love&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">);&nbsp;<br />
</font><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#0000cc">implode</font><font color="#006600">(</font><font color="#cc0000">&quot;&nbsp;&quot;</font><font color="#006600">,&nbsp;</font><font color="#0000cc">$array</font><font color="#006600">);&nbsp;<br />
</font><font color="#0000cc">例中的implode函数将数组$array的每个元素用空格字符进行连接，返回一个字符串&nbsp;$str：&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;iwind&quot;</font><font color="#006600">.&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<h5>裁剪</h5>
<p>一个字符串首和尾，可能不是你想要的部分，就可以用trim,rtrim,ltrim等函数,分别去除一个字符串两端空格，一个字符串尾部空格，一个字符串首部空格。 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">trim</font><font color="#006600">(</font><font color="#cc0000">&quot;&nbsp;i&nbsp;love&nbsp;iwind&nbsp;&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将得到&nbsp;&quot;i&nbsp;love&nbsp;iwind&quot;&nbsp;<br />
</font><font color="#006600">echo&nbsp;</font><font color="#0000cc">rtrim</font><font color="#006600">(</font><font color="#cc0000">&quot;&nbsp;i&nbsp;love&nbsp;iwind&nbsp;&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将得到&nbsp;&quot;&nbsp;i&nbsp;love&nbsp;iwind&quot;&nbsp;<br />
</font><font color="#006600">echo&nbsp;</font><font color="#0000cc">ltrim</font><font color="#006600">(</font><font color="#cc0000">&quot;&nbsp;i&nbsp;love&nbsp;iwind&nbsp;&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将得到&nbsp;&quot;i&nbsp;love&nbsp;iwind&nbsp;&quot;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>其实这三个参数不仅可以去除字符串首尾的空格，还可以去除它们的第二个参数指定的字符，如: </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">trim</font><font color="#006600">(</font><font color="#cc0000">&quot;,1,2,3,4,&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;,&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将得到&nbsp;1,2,3,4&nbsp;两端的&quot;,&quot;号被裁掉了。&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>有时还会看到有人使用chop这个函数，其实它是rtrim的同义函数。 </p>
<h5>大小写</h5>
<p>对于英文字母来说，可以用strtoupper,strtolower将其转变成大写或小写。 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">strtoupper</font><font color="#006600">(</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;iwind&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将得到&nbsp;I&nbsp;LOVE&nbsp;IWIND&nbsp;<br />
</font><font color="#006600">echo&nbsp;</font><font color="#0000cc">strtolower</font><font color="#006600">(</font><font color="#cc0000">&quot;I&nbsp;LOVE&nbsp;IWIND&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将得到&nbsp;i&nbsp;love&nbsp;iwind&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<h5>比较</h5>
<p>一般可以用 !=, == 比较两个对象是否相等，只所以说是两个对象，是因为它们不一定全部为字符串，也可以为整型等等。比如 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$a&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;joe&quot;</font><font color="#006600">;&nbsp;<br />
</font><font color="#0000cc">$b&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;jerry&quot;</font><font color="#006600">;&nbsp;<br />
if&nbsp;(</font><font color="#0000cc">$a&nbsp;</font><font color="#006600">!=&nbsp;</font><font color="#0000cc">$b</font><font color="#006600">)&nbsp;<br />
{&nbsp;<br />
echo&nbsp;</font><font color="#cc0000">&quot;不相等&quot;</font><font color="#006600">;&nbsp;<br />
}&nbsp;<br />
else&nbsp;<br />
{&nbsp;<br />
echo&nbsp;</font><font color="#cc0000">&quot;相等&quot;</font><font color="#006600">;&nbsp;<br />
}&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>如果用 !==,===(可以看到多了一个等号）比较的话，两个对象的类型要严格相等才能返回true;否则用==,!=则会将字符串自动转换成相应的类型，以便进行比较. </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">22&nbsp;</font><font color="#006600">==&nbsp;</font><font color="#cc0000">&quot;22&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;返回&nbsp;true&nbsp;<br />
</font><font color="#0000cc">22&nbsp;</font><font color="#006600">===&nbsp;</font><font color="#cc0000">&quot;22&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;返回false&nbsp;<br />
//正因为这样，所以我们的程序时常会发生一些想不到的&quot;意外&quot;：&nbsp;<br />
</font><font color="#0000cc">0&nbsp;</font><font color="#006600">==&nbsp;</font><font color="#cc0000">&quot;我爱你&quot;</font><font color="#006600">;&nbsp;</font><font color="#ff9900">//&nbsp;返回true&nbsp;<br />
</font><font color="#0000cc">1&nbsp;</font><font color="#006600">==&nbsp;</font><font color="#cc0000">&quot;1&nbsp;我爱你&quot;</font><font color="#006600">;</font><font color="#ff9900">//&nbsp;返回true&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>PHP里还有这样一组用于字符串比较的函数：strcmp,strcasecmp,strncasecmp(), strncmp()，它们都是如果前者比后者大,则返回大于0的整数；如果前者比后者小，则返回小于0的整数；如果两者相等，则返回0.它们比较的原理与其它语言的规则都是一样的。<br />
strcmp是用于区分大小写(即大小写敏感)的字符串比较： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">strcmp</font><font color="#006600">(</font><font color="#cc0000">&quot;abcdd&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;aBcde&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;返回&nbsp;1&nbsp;(&gt;0),&nbsp;比较的是&nbsp;&quot;b&quot;和&quot;B&quot;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>strcasecmp用于不区分大小写的字符串比较： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">strcasecmp</font><font color="#006600">(</font><font color="#cc0000">&quot;abcdd&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;aBcde&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;返回&nbsp;-1&nbsp;(&lt;0),&nbsp;比较的是&quot;d&quot;和&quot;e&quot;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>strncmp用于比较字符串的一部分，从字符串的开头开始比较，第三个参数，为要比较的长度： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">strncmp</font><font color="#006600">(</font><font color="#cc0000">&quot;abcdd&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;aBcde&quot;</font><font color="#006600">,&nbsp;</font><font color="#0000cc">3</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;返回&nbsp;1&nbsp;(&gt;0),&nbsp;比较了&nbsp;abc&nbsp;和&nbsp;aBc&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>strncasecmp用于不区分大小写的比较字符串的一部分，从字符串的开头开始比较，第三个参数，为要比较的长度： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">strncasecmp</font><font color="#006600">(</font><font color="#cc0000">&quot;abcdd&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;aBcde&quot;</font><font color="#006600">,&nbsp;</font><font color="#0000cc">3</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;返回&nbsp;0,&nbsp;比较了&nbsp;abc&nbsp;和&nbsp;aBc,&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>由于不区分大小写，所以两者是相同的。 </p>
<p>还有一种情况是单单比较字符串大小，达不到我们预定的要求，比如照常理 10.gif 会比 5.gif 大，但如果应用上面几个函数，就会返回 -1,即表示 10.gif比5.gif,针对这种情况，PHP提供了两个自然对比的函数strnatcmp,strnatcasecmp： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">strnatcmp</font><font color="#006600">(</font><font color="#cc0000">&quot;10.gif&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;5.gif&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;返回&nbsp;1&nbsp;(&gt;0)&nbsp;<br />
</font><font color="#006600">echo&nbsp;</font><font color="#0000cc">strnatcasecmp</font><font color="#006600">(</font><font color="#cc0000">&quot;10.GIF&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;5.gif&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;返回&nbsp;1&nbsp;(&gt;0)&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<h5>替换</h5>
<p>替换的意义在于将一个字符串的一部分进行改变，使之成为别外一个新的字符串，以满足新的要求。PHP里通常用str_replace(&quot;要替换的内容&quot;, &quot;要取代原内容的字符串&quot;, &quot;原字符串&quot;)进行替换。 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">str_replace</font><font color="#006600">(</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;kiki&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;iwind,&nbsp;iwind&nbsp;said&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将输出&nbsp;&quot;i&nbsp;love&nbsp;kiki,&nbsp;kiki&nbsp;said&quot;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>即将 原字符串中的所有&quot;iwind&quot;都替换成了&quot;kiki&quot;. </p>
<p>str_replace是大小写敏感的，所以对你不能设想用 str_replace(&quot;IWIND&quot;, &quot;kiki&quot;,&#8230;)替换原字符串中的&quot;iwind&quot;. </p>
<p>str_replace还可以实现多对一，多对多的替换，但无法实现一对多的替换： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">str_replace</font><font color="#006600">(array(</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;kiki&quot;</font><font color="#006600">),&nbsp;</font><font color="#cc0000">&quot;people&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;kiki,&nbsp;iwind&nbsp;said&quot;</font><font color="#006600">);&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>将会输出<br />
i love people, people said<br />
第一个参数中的array(&quot;iwind&quot;, &quot;kiki&quot;)都被替换成了&quot;people&quot; </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">str_replace</font><font color="#006600">(array(</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;kiki&quot;</font><font color="#006600">),&nbsp;array(</font><font color="#cc0000">&quot;gentle&nbsp;man&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;ladies&quot;</font><font color="#006600">),&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;kiki,&nbsp;iwind&nbsp;said&quot;</font><font color="#006600">);&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>输出 i love ladies, gentle man said 。也就是说第一个数组中的元素被第二个数组中的相对应的元素替换掉了，如果有一个数组比另一个数组元素数要少，那么不足的都会当作空来处理。 </p>
<p>与此有些类似的是strtr,用法请参阅手册,它们的比较请参阅 http://diary.4kiki.net/index.php?action=info&amp;id=372 . </p>
<p>此外，PHP还提供了substr_replace,实现替换一部分的字符串。语法如下：<br />
substr_replace (原字符串, 要替代的字符串, 开始替换的位置 [, 替换的长度])<br />
其中，开始替换的位置从0开始计算，应该小于原字符串的长度。要替换的长度是可选的。 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">substr_replace</font><font color="#006600">(</font><font color="#cc0000">&quot;abcdefgh&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;DEF&quot;</font><font color="#006600">,&nbsp;</font><font color="#0000cc">3</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将输出&nbsp;&quot;abcDEF&quot;&nbsp;<br />
</font><font color="#006600">echo&nbsp;</font><font color="#0000cc">substr_replace</font><font color="#006600">(</font><font color="#cc0000">&quot;abcdefgh&quot;</font><font color="#006600">,&nbsp;</font><font color="#cc0000">&quot;DEF&quot;</font><font color="#006600">,&nbsp;</font><font color="#0000cc">3</font><font color="#006600">,&nbsp;</font><font color="#0000cc">2</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将输出&nbsp;&quot;abcDEFfgh&quot;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>第一个例子中，从第三个位置（即&quot;d&quot;)开始替换，从而把 &quot;defgh&quot;都替换成了&ldquo;DEF&rdquo;<br />
第二个例子中，也是从第三个位置（即&quot;d&quot;)开始替换，但只能替换2个长度，即到e,所以就把&quot;de&quot;替换成了&quot;DEF&quot;. </p>
<p>PHP还提供了preg_replace,preg_replace_callback,ereg_replace,eregi_replace等函数应用正则表达式来完成字符串替换,用法请参考手册。 </p>
<h5>查找与匹配</h5>
<p>PHP里用于查找或者匹配或者定位的函数非常多，它们都有不同的意义。这里只讲述用得比较多的strstr,stristr.后者与前者的功能，返回值都一样，只是不区分大小写。<br />
strstr(&quot;母字符串&quot;, &quot;子字符串&quot;)用来查找子字符串在母字符串中第一次出现的位置,并返回母字符串中从子字符串开始到母字符串结束的部分。比如<br />
echo strstr(&quot;abcdefg&quot;, &quot;e&quot;); //将输出 &quot;efg&quot;<br />
如果找不到子字符串，则返回空。因为可以用来判断一个字符串中是否含有另外一个字符串： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$needle&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;iwind&quot;</font><font color="#006600">;&nbsp;<br />
</font><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;iwind&quot;</font><font color="#006600">;&nbsp;<br />
if&nbsp;(</font><font color="#0000cc">strstr</font><font color="#006600">(</font><font color="#0000cc">$str</font><font color="#006600">,&nbsp;</font><font color="#0000cc">$needle</font><font color="#006600">))&nbsp;<br />
{&nbsp;<br />
echo&nbsp;</font><font color="#cc0000">&quot;里面有&nbsp;iwind&quot;</font><font color="#006600">;&nbsp;<br />
}&nbsp;<br />
else&nbsp;<br />
{&nbsp;<br />
echo&nbsp;</font><font color="#cc0000">&quot;里面没有&nbsp;iwind&quot;</font><font color="#006600">;&nbsp;<br />
}&nbsp;<br />
</font><font color="#0000cc">将会输出</font><font color="#cc0000">&quot;里面有&nbsp;iwind&quot;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<h5>HTML相关</h5>
<p>1,htmlspecialchars($string)<br />
这是它的最简单用法，将字符串中的一些特殊字符（顾名思义）&amp;,&#8217;,&quot;&lt;,&gt;转换成它们对应的HTML实体形式： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;&lt;font&nbsp;color=&quot;red&quot;&gt;kiki&lt;/font&gt;,&nbsp;iwind&nbsp;said.&quot;</font><font color="#006600">;&nbsp;<br />
echo&nbsp;</font><font color="#0000cc">htmlspecialchars</font><font color="#006600">(</font><font color="#0000cc">$str</font><font color="#006600">);&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>将会输出<br />
i love &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;kiki&amp;lt;/font&amp;gt;, iwind said. </p>
<p>2,htmlentities($string)<br />
将所有能转换成实体形式的字符都转换成实体形式。 </p>
<p>3,html_entity_decode($string);<br />
PHP4.3.0以后加入的具有与htmlentities($string)相反的功能。 </p>
<p>4,nl2br($string)<br />
将字符串中所有换行符转变成&lt;br /&gt; + 换行符。如： </p>
<div class='example'><code><font color="#000000"><font color="#0000cc">$str&nbsp;</font><font color="#006600">=&nbsp;</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;kiki,n&nbsp;iwind&nbsp;said.&quot;</font><font color="#006600">;&nbsp;<br />
echo&nbsp;</font><font color="#0000cc">nl2br</font><font color="#006600">(</font><font color="#0000cc">$str</font><font color="#006600">);&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>将会输出<br />
i love kiki,&lt;br /&gt;<br />
iwind said. </p>
<h5>加密</h5>
<p>加密字符串最常用的就是md5了，它将一个字符串转换成一个长32位的唯一的字符串。 </p>
<div class='example'><code><font color="#000000"><font color="#0000cc"></font><font color="#006600">echo&nbsp;</font><font color="#0000cc">md5</font><font color="#006600">(</font><font color="#cc0000">&quot;i&nbsp;love&nbsp;iwind&quot;</font><font color="#006600">);&nbsp;</font><font color="#ff9900">//&nbsp;将输出&nbsp;&quot;2df89f86e194e66dc54b30c7c464c21c&quot;&nbsp;</font><font color="#0000cc"></font> </font></code></div>
<p>PHP5给md5加了第二个参数，从而使它可以输出16位的加密后的字符串。 </p>
<p>到这里，这篇字符串操作入门教程就算结束了，但上面讲的这些还只是它的冰山一角，特别是PHP5之后增加了大量的新功能，所以需要我们不断的去学习它才有可能很好的应用。 </p>

<p><a href="http://feedads.g.doubleclick.net/~a/TVGEQeUbHxGvK6-5vZiVCY5gJrM/0/da"><img src="http://feedads.g.doubleclick.net/~a/TVGEQeUbHxGvK6-5vZiVCY5gJrM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/TVGEQeUbHxGvK6-5vZiVCY5gJrM/1/da"><img src="http://feedads.g.doubleclick.net/~a/TVGEQeUbHxGvK6-5vZiVCY5gJrM/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NpBTPS7m80M:JqdXWhxnzDQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NpBTPS7m80M:JqdXWhxnzDQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=NpBTPS7m80M:JqdXWhxnzDQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NpBTPS7m80M:JqdXWhxnzDQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NpBTPS7m80M:JqdXWhxnzDQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=NpBTPS7m80M:JqdXWhxnzDQ:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/NpBTPS7m80M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/10/php-string/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/10/php-string/</feedburner:origLink></item>
		<item>
		<title>中金岭南需提高报价收购HER[分析]</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/OUlH2f9tF5A/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/08/%e4%b8%ad%e9%87%91%e5%b2%ad%e5%8d%97%e9%9c%80%e6%8f%90%e9%ab%98%e6%8a%a5%e4%bb%b7%e6%94%b6%e8%b4%adher%e5%88%86%e6%9e%90/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 06:03:28 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[我的股市预判]]></category>
		<category><![CDATA[财金与投资]]></category>
		<category><![CDATA[预测]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=230</guid>
		<description><![CDATA[中金岭南今日收购HER要约终止日，很多中金岭南股民在抱怨信息不公开。其实澳大利亚ASX市场是个信息很公开的市场。被收购方HER每天都在向市场发布最新收购消息，且信息都为公司一手文件的传真件，消息的准确与公开性都是国内股市不可比拟的。我们可以随便在一个AU财金网站上得到，如：http://markets.smh.com.au/apps/qt/quote.ac?section=ca&#038;code=HER�
从公开信息分析，除非提高报价，中金岭南收购HER将不会成功。理由如下。
1. 60%HER股民不满2.8$报价，这从今天市价2.9$，与Calipso提高报价到2.85$后只有增加0.1%不到股民接受要约看出。
2. 有两家已提高报价至2.85$,其中包括Calipso。
3. 在同等条件下澳洲普通股民更愿意把股权卖给澳洲公司。大家要注意到Tango与Calipso同时提出2.8$收购要约时两家都获得19%多的股权支持，但Tangou的主要支持方为公司管理层，Calipso为普通股民。管理层知道Tango是唯一最终收购方，为保持与以后的大股东关系，管理层做出了正确的选择。但其他普通股民明显和Calipso一样想从中获得额外的利润，不愿过早释出手中筹码。
中金岭南要获得HER可能要提高血本来填补澳洲市场的胃口。
让我拭目以待吧！
]]></description>
			<content:encoded><![CDATA[<p>中金岭南今日收购<a href="http://www.herald.net.au/">HER</a>要约终止日，很多中金岭南股民在抱怨信息不公开。其实澳大利亚ASX市场是个信息很公开的市场。被收购方HER每天都在向市场发布最新收购消息，且信息都为公司一手文件的传真件，消息的准确与公开性都是国内股市不可比拟的。我们可以随便在一个AU财金网站上得到，如：http://markets.smh.com.au/apps/qt/quote.ac?section=ca&#038;code=HER。</p>
<p>从公开信息分析，除非提高报价，中金岭南收购HER将不会成功。理由如下。<br />
1. 60%HER股民不满2.8$报价，这从今天市价2.9$，与Calipso提高报价到2.85$后只有增加0.1%不到股民接受要约看出。<br />
2. 有两家已提高报价至2.85$,其中包括Calipso。<br />
3. 在同等条件下澳洲普通股民更愿意把股权卖给澳洲公司。大家要注意到Tango与Calipso同时提出2.8$收购要约时两家都获得19%多的股权支持，但Tangou的主要支持方为公司管理层，Calipso为普通股民。管理层知道Tango是唯一最终收购方，为保持与以后的大股东关系，管理层做出了正确的选择。但其他普通股民明显和Calipso一样想从中获得额外的利润，不愿过早释出手中筹码。</p>
<p>中金岭南要获得HER可能要提高血本来填补澳洲市场的胃口。<br />
让我拭目以待吧！</p>

<p><a href="http://feedads.g.doubleclick.net/~a/F3RQdG09UtFWYD1CWy4N4_LUxaU/0/da"><img src="http://feedads.g.doubleclick.net/~a/F3RQdG09UtFWYD1CWy4N4_LUxaU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/F3RQdG09UtFWYD1CWy4N4_LUxaU/1/da"><img src="http://feedads.g.doubleclick.net/~a/F3RQdG09UtFWYD1CWy4N4_LUxaU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=OUlH2f9tF5A:Ohl16JvMMMg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=OUlH2f9tF5A:Ohl16JvMMMg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=OUlH2f9tF5A:Ohl16JvMMMg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=OUlH2f9tF5A:Ohl16JvMMMg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=OUlH2f9tF5A:Ohl16JvMMMg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=OUlH2f9tF5A:Ohl16JvMMMg:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/OUlH2f9tF5A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/08/%e4%b8%ad%e9%87%91%e5%b2%ad%e5%8d%97%e9%9c%80%e6%8f%90%e9%ab%98%e6%8a%a5%e4%bb%b7%e6%94%b6%e8%b4%adher%e5%88%86%e6%9e%90/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/08/%e4%b8%ad%e9%87%91%e5%b2%ad%e5%8d%97%e9%9c%80%e6%8f%90%e9%ab%98%e6%8a%a5%e4%bb%b7%e6%94%b6%e8%b4%adher%e5%88%86%e6%9e%90/</feedburner:origLink></item>
		<item>
		<title>PHP的debug技术</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/iVxHWjVWxsU/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/07/php%e7%9a%84debug%e6%8a%80%e6%9c%af/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 12:55:46 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=229</guid>
		<description><![CDATA[给程序加上debug函数，来记录其他代码的结果， DEBUG为开关。 代码来源：wp-global-translator-plugin。

?Download degug.php1
2
3
4
5
6
7
8
9
10
11
function debug&#40;$msg&#41;
&#123;
  if &#40;DEBUG&#41; &#123;
    $today = date&#40;&#34;Y-m-d H:i:s &#34;&#41;;
    $myFile = dirname&#40;__file__&#41; . &#34;/debug.log&#34;;
    $fh = fopen&#40;$myFile, 'a'&#41; or die&#40;&#34;Can't open debug file. Please manually create the 'debug.log' file (inside the 'global-translator' directory) and make it writable.&#34;&#41;;
    $ua_simple [...]]]></description>
			<content:encoded><![CDATA[<p>给程序加上debug函数，来记录其他代码的结果， DEBUG为开关。 代码来源：wp-global-translator-plugin。</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.ericbess.com/ericblog/wp-content/plugins/wp-codebox/wp-codebox.php?p=229&amp;download=degug.php">degug.php</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22945"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p229code45"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> debug<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d H:i:s &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$myFile</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__file__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/debug.log&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$fh</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFile</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Can't open debug file. Please manually create the 'debug.log' file (inside the 'global-translator' directory) and make it writable.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$ua_simple</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/(.*)\s\(.*/&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>1&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #339933;">,</span> <span style="color: #000088;">$today</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; [from: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;|<span style="color: #006699; font-weight: bold;">$ua_simple</span>] - &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$msg</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>在程序的其他部分，需要时加上debug(&#8221;")记录结果，如下面求当前URI的散列表现：$hash。</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p229code46'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22946"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p229code46"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> gltr_get_page_content<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lang</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>USE_CACHE<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$refresh</span> <span style="color: #339933;">=</span> CACHE_TIMEOUT<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/(.*)\/$/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\1'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/#.*$/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$req</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'?'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&gt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">':'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'\\'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'*'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'|'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot;'</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: #000088;">$req</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    debug<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hashing uri: <span style="color: #006699; font-weight: bold;">$req</span> to: <span style="color: #006699; font-weight: bold;">$hash</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #339933;">.......</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/lveFQCy9hKzRJie31YyLlGQrn8o/0/da"><img src="http://feedads.g.doubleclick.net/~a/lveFQCy9hKzRJie31YyLlGQrn8o/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/lveFQCy9hKzRJie31YyLlGQrn8o/1/da"><img src="http://feedads.g.doubleclick.net/~a/lveFQCy9hKzRJie31YyLlGQrn8o/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=iVxHWjVWxsU:DXoYO9VwX1E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=iVxHWjVWxsU:DXoYO9VwX1E:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=iVxHWjVWxsU:DXoYO9VwX1E:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=iVxHWjVWxsU:DXoYO9VwX1E:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=iVxHWjVWxsU:DXoYO9VwX1E:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=iVxHWjVWxsU:DXoYO9VwX1E:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/iVxHWjVWxsU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/07/php%e7%9a%84debug%e6%8a%80%e6%9c%af/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/07/php%e7%9a%84debug%e6%8a%80%e6%9c%af/</feedburner:origLink></item>
		<item>
		<title>Rewrite Permalinks in plugin development.</title>
		<link>http://feedproxy.google.com/~r/ericbess-eric/~3/wp2k4lwOITY/</link>
		<comments>http://www.ericbess.com/ericblog/2008/07/07/rewrite-permalinks-in-plugin-development/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 06:06:18 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[WP Programming]]></category>
		<category><![CDATA[WP-Coding]]></category>

		<guid isPermaLink="false">http://www.ericbess.com/ericblog/?p=227</guid>
		<description><![CDATA[ We add a rewrite rule that tells WordPress to interpret /geostate/oregon URLs the same as ?geostate=oregon.
there are two steps: 

(1) &#8220;flush&#8221; the cached rewrite rules using an init filter, to force WordPress to recalculate the rewrite rules,



add_action('init', 'geotags_flush_rewrite_rules');

function geotags_flush_rewrite_rules()
{
   global $wp_rewrite;
   $wp_rewrite->flush_rules();
}



(2) use the generate_rewrite_rules action to add a new [...]]]></description>
			<content:encoded><![CDATA[<p> We add a rewrite rule that tells WordPress to interpret <em>/geostate/oregon </em>URLs the same as <em>?geostate=oregon</em>.<br />
there are two steps: </p>
<div class=note>
(1) &#8220;flush&#8221; the cached rewrite rules using an init filter, to force WordPress to recalculate the rewrite rules,
</div>
<div class=example>
<pre>
add_action('init', 'geotags_flush_rewrite_rules');

function geotags_flush_rewrite_rules()
{
   global $wp_rewrite;
   $wp_rewrite->flush_rules();
}
</pre>
</div>
<div class=note>
(2) use the generate_rewrite_rules action to add a new rule when they are calculated. Here&#8217;s the &#8220;flush&#8221; code:
</div>
<div class=example>
<pre>
add_action('generate_rewrite_rules', 'geotags_add_rewrite_rules');

function geotags_add_rewrite_rules( $wp_rewrite )
{
  $new_rules = array(
     'geostate/(.+)' => 'index.php?geostate=' .
       $wp_rewrite->preg_index(1) );

  $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
</pre>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/7aEiUfhMJaCX4jxMGzzxC1JKyJQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/7aEiUfhMJaCX4jxMGzzxC1JKyJQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/7aEiUfhMJaCX4jxMGzzxC1JKyJQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/7aEiUfhMJaCX4jxMGzzxC1JKyJQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wp2k4lwOITY:qMk56_aM8dA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wp2k4lwOITY:qMk56_aM8dA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?i=wp2k4lwOITY:qMk56_aM8dA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wp2k4lwOITY:qMk56_aM8dA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wp2k4lwOITY:qMk56_aM8dA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ericbess-eric?a=wp2k4lwOITY:qMk56_aM8dA:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/ericbess-eric?d=l6gmwiTKsz0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ericbess-eric/~4/wp2k4lwOITY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ericbess.com/ericblog/2008/07/07/rewrite-permalinks-in-plugin-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ericbess.com/ericblog/2008/07/07/rewrite-permalinks-in-plugin-development/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 4.461 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-11-05 22:33:47 -->
