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

<channel>
	<title>蓝色的华 &#187; php</title>
	<atom:link href="http://bluehua.org/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://bluehua.org</link>
	<description>分享所学,backup一切~</description>
	<lastBuildDate>Wed, 23 Nov 2011 08:43:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>日历的重复事件预测</title>
		<link>http://bluehua.org/2010/08/11/1417.html</link>
		<comments>http://bluehua.org/2010/08/11/1417.html#comments</comments>
		<pubDate>Wed, 11 Aug 2010 15:12:06 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[repeat event]]></category>

		<guid isPermaLink="false">http://bluehua.org/2010/08/11/1417.html</guid>
		<description><![CDATA[本周开发一个web行事历，遇到一个比较繁琐的问题，就是重复事件。比如我创建了一个每周1,3,5重复的事件，当点击2012年的某月的日历时，需要显示这个事件会在哪几天发生。我又偷懒的去google找PHP源码，这回真的没有&#8230;,于是按照正常的想法实现了一个,不知道有没有更好的实现~ 简述如下: 恩，问题描述出来就是找出特定规则的重复事件E在日期DA和日期DB之间会发生的日期，那么俺先粗略的在日期DA之前找一个事件E会发生日期DC然后从DC开始严格按照重复规则遍历,找出所有事件发生日期。 源代码: http://code-of-emptyhua.googlecode.com/svn/trunk/phplib/calutil.class.php &#8212;&#8212;&#8212;&#8211; post by gmail~]]></description>
			<content:encoded><![CDATA[<p>本周开发一个web行事历，遇到一个比较繁琐的问题，就是重复事件。比如我创建了一个每周1,3,5重复的事件，当点击2012年的某月的日历时，需要显示这个事件会在哪几天发生。我又偷懒的去google找PHP源码，这回真的没有&#8230;,于是按照正常的想法实现了一个,不知道有没有更好的实现~<br />
简述如下:<br />
恩，问题描述出来就是找出特定规则的重复事件E在日期DA和日期DB之间会发生的日期，那么俺先粗略的在日期DA之前找一个事件E会发生日期DC然后从DC开始严格按照重复规则遍历,找出所有事件发生日期。</p>
<p>源代码:<br />
<a href="http://code-of-emptyhua.googlecode.com/svn/trunk/phplib/calutil.class.php">http://code-of-emptyhua.googlecode.com/svn/trunk/phplib/calutil.class.php</a></p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
post by gmail~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/08/11/1417.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vim里快速调试PHP</title>
		<link>http://bluehua.org/2010/07/28/1407.html</link>
		<comments>http://bluehua.org/2010/07/28/1407.html#comments</comments>
		<pubDate>Wed, 28 Jul 2010 13:10:18 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://bluehua.org/2010/07/28/1407.html</guid>
		<description><![CDATA[恩，python中一般会把调试代码跟普通代码混在一块 class xx: # ..... if __name__ == '__main__': testxx = xx&#40;&#41; #测试代码.... 这个__name__ == &#8216;__main__&#8217;判断此文件是否被直接执行，而不是被其他文件import,所以在vim中调试时可以直接输入:!python % 执行当前正在编辑的文件,调试代码便会执行并输出结果 php也可以这么加调试代码,php中是这么实现的 class xx &#123; // ...... &#125; //确定当前被执行的文件就是自己,而不是被其他php文件包含 if &#40;realpath&#40;$_SERVER&#91;'SCRIPT_FILENAME'&#93;&#41; == __FILE__&#41; &#123; $testxx = new xx; //测试代码.... &#125; 如果仅限在命令行运行测试代码就再加个条件 if &#40;php_sapi_name&#40;&#41; == 'cli' &#38;&#38; realpath&#40;$_SERVER&#91;'SCRIPT_FILENAME'&#93;&#41; == __FILE__&#41; 为了更速度，vim配置里添加了一个快捷键F5 &#34;php和python调试快捷键 au FileType php map &#60;F5&#62; :call DebugRun&#40;'php'&#41;&#60;cr&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>恩，python中一般会把调试代码跟普通代码混在一块</p>

<div class="wp_syntax"><div class="code overflow"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> xx:
<span style="color: #808080; font-style: italic;">#    .....</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    testxx = xx<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #808080; font-style: italic;">#测试代码....</span></pre></div></div>

<p>这个__name__ == &#8216;__main__&#8217;判断此文件是否被直接执行，而不是被其他文件import,所以在vim中调试时可以直接输入:!python % 执行当前正在编辑的文件,调试代码便会执行并输出结果</p>
<p>php也可以这么加调试代码,php中是这么实现的</p>

<div class="wp_syntax"><div class="code overflow"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> xx <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// ......</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//确定当前被执行的文件就是自己,而不是被其他php文件包含</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_FILENAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$testxx</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> xx<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//测试代码....</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>如果仅限在命令行运行测试代码就再加个条件</p>

<div class="wp_syntax"><div class="code overflow"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">php_sapi_name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'cli'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_FILENAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>为了更速度，vim配置里添加了一个快捷键F5</p>

<div class="wp_syntax"><div class="code overflow"><pre class="vim" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">&quot;php和python调试快捷键</span>
au FileType php <span style="color: #25BB4D;">map</span> <span style="color: #000000;">&lt;</span>F5<span style="color: #000000;">&gt;</span> <span style="color: #000000;">:</span><span style="color: #804040;">call</span> DebugRun<span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'php'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&lt;</span>cr<span style="color: #000000;">&gt;</span>
au FileType php imap <span style="color: #000000;">&lt;</span>F5<span style="color: #000000;">&gt;</span> <span style="color: #000000;">&lt;</span>Esc<span style="color: #000000;">&gt;:</span><span style="color: #804040;">call</span> DebugRun<span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'php'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&lt;</span>cr<span style="color: #000000;">&gt;</span>
au FileType python <span style="color: #25BB4D;">map</span> <span style="color: #000000;">&lt;</span>F5<span style="color: #000000;">&gt;</span> <span style="color: #000000;">:</span><span style="color: #804040;">call</span> DebugRun<span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'python'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&lt;</span>cr<span style="color: #000000;">&gt;</span>
au FileType python imap <span style="color: #000000;">&lt;</span>F5<span style="color: #000000;">&gt;</span> <span style="color: #000000;">&lt;</span>Esc<span style="color: #000000;">&gt;:</span><span style="color: #804040;">call</span> DebugRun<span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'python'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&lt;</span>cr<span style="color: #000000;">&gt;</span>
<span style="color: #804040;">function</span> DebugRun<span style="color: #000000;">&#40;</span>cmd<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">:</span>w
    <span style="color: #804040;">execute</span> <span style="color: #C5A22D;">'!'</span> <span style="color: #000000;">.</span> a<span style="color: #000000;">:</span>cmd <span style="color: #000000;">.</span> <span style="color: #C5A22D;">' %'</span>
endfunction</pre></div></div>

<p>OK,写完调试代码按下F5立刻有结果。</p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
post by gmail~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/07/28/1407.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>last_insert_id脑残?</title>
		<link>http://bluehua.org/2010/07/21/1391.html</link>
		<comments>http://bluehua.org/2010/07/21/1391.html#comments</comments>
		<pubDate>Wed, 21 Jul 2010 10:39:52 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[last_insert_id]]></category>
		<category><![CDATA[mysql_insert_id]]></category>

		<guid isPermaLink="false">http://bluehua.org/2010/07/21/1391.html</guid>
		<description><![CDATA[//前面插入操作省略... $rt = mysql_insert_id&#40;&#41;; var_dump&#40;$rt&#41;; $rt = $this-&#62;DB-&#62;query&#40;&#34;select last_insert_id() from yl_contact&#34;&#41;; var_dump&#40;$rt&#41;; //结果 // //int(10000672) //int(15476) 10000672这个结果是准确的，15476是索引总量，也就是说这个表里的自增字段有一段是空的，但是有影响吗？ 为什么mysql_insert_id()这个函数这么靠普呢? 因为它直接返回了上次插入返回结果里的insert_id my_ulonglong STDCALL mysql_insert_id&#40;MYSQL *mysql&#41; &#123; return mysql-&#62;last_used_con-&#62;insert_id; &#125; 还是没弄明白为什么，求解~ &#8212;&#8212;&#8212;&#8211; post by gmail~]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code overflow"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//前面插入操作省略...</span>
<span style="color: #000088;">$rt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_insert_id</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DB</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select last_insert_id() from yl_contact&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//结果</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//int(10000672)</span>
<span style="color: #666666; font-style: italic;">//int(15476)</span></pre></div></div>

<p>10000672这个结果是准确的，15476是索引总量，也就是说这个表里的自增字段有一段是空的，但是有影响吗？</p>
<p>为什么mysql_insert_id()这个函数这么靠普呢? 因为它直接返回了上次插入返回结果里的insert_id</p>

<div class="wp_syntax"><div class="code overflow"><pre class="c" style="font-family:monospace;">my_ulonglong STDCALL mysql_insert_id<span style="color: #009900;">&#40;</span>MYSQL <span style="color: #339933;">*</span>mysql<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> mysql<span style="color: #339933;">-&gt;</span>last_used_con<span style="color: #339933;">-&gt;</span>insert_id<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>还是没弄明白为什么，求解~</p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
post by gmail~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/07/21/1391.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>php2wsdl</title>
		<link>http://bluehua.org/2010/07/13/1336.html</link>
		<comments>http://bluehua.org/2010/07/13/1336.html#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:16:46 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[webservice]]></category>
		<category><![CDATA[wsdl]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1336</guid>
		<description><![CDATA[搞webservice最痛苦的莫过于提供wsdl，前两天找到一个叫”PHP WSDL Generator”的工具，可以根据注释生成wsdl，刚开始写了一个测试类还行，后来发现问题多多，文件里有require一类引用外部文件时会出问题，写同样的注释有的函数可以正确的生成，有的函数却不行。这种深不可测的东西不用也罢，自己写了一个。虽然功能弱点，但是不会无厘头。 下载:http://code-of-emptyhua.googlecode.com/svn/trunk/php2wsdl.py 命令行的话这样： #参数依次为 命名空间 提供服务的PHP的类名 soap访问地址 本地的PHP文件 生成wsd的保存地址 php2wsdl.py &#34;Ox-Service&#34; &#34;SomeClass&#34; &#34;http://test.com/soapserver.php&#34; ./SomeClass.php ./service.wsdl 图简单，这个脚本生成的wsdl会把array类型当成anyType,实际用的时候没有什么问题～ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 另: 打包上传比较麻烦，以后就用google code传东西了，也比较好管理 跟上面一块传的还有一段汉字转拼音的python脚本:http://code-of-emptyhua.googlecode.com/svn/trunk/hz2py，写这个脚本因为最近想注个好点的com域名，但是差来查去都被注册，难道好记点的域名真的光了吗。。于是从一个分词字典里生成了一个快5万个域名的txt，跑了一个whois脚本，最后结果没有注册只有不到300个，而且基本都是多音字。。只能叹生不逢时~]]></description>
			<content:encoded><![CDATA[<p>搞webservice最痛苦的莫过于提供wsdl，前两天找到一个叫”PHP WSDL Generator”的工具，可以根据注释生成wsdl，刚开始写了一个测试类还行，后来发现问题多多，文件里有require一类引用外部文件时会出问题，写同样的注释有的函数可以正确的生成，有的函数却不行。这种深不可测的东西不用也罢，自己写了一个。虽然功能弱点，但是不会无厘头。</p>
<p>下载:<a href="http://code-of-emptyhua.googlecode.com/svn/trunk/php2wsdl.py">http://code-of-emptyhua.googlecode.com/svn/trunk/php2wsdl.py</a></p>
<p>命令行的话这样：</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#参数依次为 命名空间 提供服务的PHP的类名 soap访问地址 本地的PHP文件 生成wsd的保存地址</span>
php2wsdl.py <span style="color: #ff0000;">&quot;Ox-Service&quot;</span> <span style="color: #ff0000;">&quot;SomeClass&quot;</span> <span style="color: #ff0000;">&quot;http://test.com/soapserver.php&quot;</span> .<span style="color: #000000; font-weight: bold;">/</span>SomeClass.php .<span style="color: #000000; font-weight: bold;">/</span>service.wsdl</pre></div></div>

<p>图简单，这个脚本生成的wsdl会把array类型当成anyType,实际用的时候没有什么问题～</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
另:<br />
打包上传比较麻烦，以后就用google code传东西了，也比较好管理<br />
跟上面一块传的还有一段汉字转拼音的python脚本:<a href="http://code-of-emptyhua.googlecode.com/svn/trunk/hz2py">http://code-of-emptyhua.googlecode.com/svn/trunk/hz2py</a>，写这个脚本因为最近想注个好点的com域名，但是差来查去都被注册，难道好记点的域名真的光了吗。。于是从一个分词字典里生成了一个快5万个域名的txt，跑了一个whois脚本，最后结果没有注册只有不到300个，而且基本都是多音字。。只能叹生不逢时~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/07/13/1336.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php的一个表单验证类</title>
		<link>http://bluehua.org/2010/04/23/1150.html</link>
		<comments>http://bluehua.org/2010/04/23/1150.html#comments</comments>
		<pubDate>Fri, 23 Apr 2010 15:19:36 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[web dev]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[validate]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1150</guid>
		<description><![CDATA[做web这么长时间,感觉最恶心的就是表单验证这块了,很无聊,很烦琐,也很重要.. 这个验证类的功能参考了codeigniter的表单验证库的功能,按照我的想法实现完毕又去对照codeigniter的代码,感觉还是我的这个比较灵活实用&#8230; /** * 表单验证类 * Author : emptyhua@gmail.com * Version : beta */ &#160; class FormValidator &#123; //所有验证函数定义时的前缀 const PREFIX = 'form_validator_'; &#160; //存储验证函数的出错信息 public static $error_messages = array&#40;&#41;; &#160; //存储验证相关的数据 protected $valid_rules = array&#40;&#41;; &#160; //存储上次验证的出错信息 protected $errors = array&#40;&#41;; &#160; //是否完全检查 protected $complete_check = true; &#160; public static function set_error&#40;$rule, $error&#41; &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>做web这么长时间,感觉最恶心的就是表单验证这块了,很无聊,很烦琐,也很重要..<br />
这个验证类的功能参考了<a href="http://codeigniter.org.cn/user_guide/libraries/form_validation.html">codeigniter的表单验证库</a>的功能,按照我的想法实现完毕又去对照codeigniter的代码,感觉还是我的这个比较灵活实用<img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/msn/bofu1_12.gif" border="0" alt="" />&#8230;</p>

<div class="wp_syntax"><div class="code overflow"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * 表单验证类
 * Author : emptyhua@gmail.com
 * Version : beta
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> FormValidator
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//所有验证函数定义时的前缀</span>
    <span style="color: #000000; font-weight: bold;">const</span> PREFIX <span style="color: #339933;">=</span> <span style="color: #0000ff;">'form_validator_'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//存储验证函数的出错信息</span>
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000088;">$error_messages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//存储验证相关的数据</span>
    protected <span style="color: #000088;">$valid_rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">//存储上次验证的出错信息</span>
    protected <span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//是否完全检查</span>
    protected <span style="color: #000088;">$complete_check</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> set_error<span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #339933;">,</span> <span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$error_messages</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$rule</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$error</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 遇到第一个错误便返回
     */</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> first_error_only<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">complete_check</span> <span style="color: #339933;">=</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: #009933; font-style: italic;">/**
     * 执行所有验证规则,收集所有错误
     */</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> show_all_errors<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">complete_check</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 设置验证规则
     * @param string $var 验证的变量名,例如 username
     * @param string $var_name 变量名的描述,例如 用户名
     * @param string $func_name 验证规则,可以是多个,并且可以传参,例如 require|length(9,12)
     * @param string $error_message 自定义的出错信息,可选,如果给定将覆盖验证函数的默认出错信息
     */</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> set_rules<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #339933;">,</span> <span style="color: #000088;">$var_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$func_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$error_message</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'var_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var_name</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'error'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$error_message</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'funcs'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$funcs_with_arg</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$func_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$args_match</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//解析验证规则</span>
        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$funcs_with_arg</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$func_with_arg</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\((.*)\)$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$func_with_arg</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args_match</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #666666; font-style: italic;">//规则函数是否携带参数</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args_match</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//参数列表</span>
                <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args_match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//去掉参数后的验证规则名</span>
                <span style="color: #000088;">$func</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'('</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$args_match</span><span style="color: #009900;">&#91;</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: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$func_with_arg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'funcs'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$func</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$args</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;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'funcs'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$func_with_arg</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">valid_rules</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 检验一组数据是否合法
     * @param array $data 一个关联数组
     * @return boolean
     */</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> is_valid<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$valid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//遍历的顺序为规则添加的顺序</span>
        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">valid_rules</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$var</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$rule</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//判断数据中是否有此字段,没有的话置一个空的</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
                <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'funcs'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$func</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//真实的验证函数的名称,例如 form_validator_require</span>
                <span style="color: #000088;">$func_run</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">PREFIX</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$func</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//如果函数未定义,循环继续</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_callable</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$func_run</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">//为验证函数组装参数</span>
                <span style="color: #666666; font-style: italic;">//顺序为:当前验证字段的值, 所有验证数据, 验证规则参数1, ...</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$args</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">NULL</span> <span style="color: #009900;">&#41;</span> 
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">else</span>
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #990000;">array_unshift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #990000;">array_unshift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">//调用验证函数</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">call_user_func_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$func_run</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$valid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                    <span style="color: #666666; font-style: italic;">//如果set_rules的时候没有自定义错误信息,则使用默认出错信息</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$rule</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'error'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">NULL</span> <span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">//使用sprintf拼接错误信息</span>
                        <span style="color: #666666; font-style: italic;">//参数顺序: 验证字段的描述, 验证函数的参数1, 验证函数的参数2 ...</span>
&nbsp;
                        <span style="color: #666666; font-style: italic;">//去掉刚才添加的字段值</span>
                        <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #666666; font-style: italic;">//去掉刚才添加的所有验证数据</span>
                        <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #666666; font-style: italic;">//添加字段名的描述</span>
                        <span style="color: #990000;">array_unshift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rule</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'var_name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #666666; font-style: italic;">//添加默认的出错信息</span>
                        <span style="color: #990000;">array_unshift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$error_messages</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$func</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">call_user_func_array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sprintf'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #b1b100;">else</span>
                    <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">//使用自定义错误信息</span>
                        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rule</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'error'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">continue</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
&nbsp;
                    <span style="color: #666666; font-style: italic;">//如果设置不进行完全检查,则发现第一个错误后跳出最外层循环</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">complete_check</span> <span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">break</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> 
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$valid</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 获取出错信息
     * @return string array
     */</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get_errors<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errors</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 返回第一条出错信息
     * @return string
     */</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get_first_error<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errors</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//扩展验证规则很方便~</span>
<span style="color: #666666; font-style: italic;">//设置规则的默认出错信息</span>
FormValidator<span style="color: #339933;">::</span><span style="color: #004000;">set_error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'require'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%s不能为空'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//定义验证函数,以FormValidator::PREFIX打头</span>
<span style="color: #000000; font-weight: bold;">function</span> form_validator_require<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</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;">&#40;</span><span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</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;">&#125;</span>
&nbsp;
FormValidator<span style="color: #339933;">::</span><span style="color: #004000;">set_error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'equal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'重复输入不一致'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> form_validator_equal<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$eqto</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: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$eqto</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;">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: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$eqto</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>使用方法</p>

<div class="wp_syntax"><div class="code overflow"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$vd</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FormValidator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$vd</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'p'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'密码'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'require|length(9,12)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$vd</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'p2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'密码验证'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'equa(p)'</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$vd</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_valid</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$vd</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_errors</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/04/23/1150.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>php整型溢出导致的小问题~</title>
		<link>http://bluehua.org/2010/03/29/1046.html</link>
		<comments>http://bluehua.org/2010/03/29/1046.html#comments</comments>
		<pubDate>Mon, 29 Mar 2010 15:58:20 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[debug]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1046</guid>
		<description><![CDATA[今天把一直本地测试的php程序放到外网的机器跑(64位系统),没想到一个纯算数值的算法竟然得到不一样的结果,最后锁定在一个求模的操作上:$i % 4, $i在本地和server上打印出来都是434807526976, 但是求出来的结果却不一样~ 原因是: php的整型最大值为2147483647(32位系统上), 当数值赋值超过这个最大值时,变量便自动成为浮点型. 所以虽然打印出来一样,但本地打印的是一个是浮点型的$i,而server上是64位系统,整型最大值达到9223372036854775807  &#8230;. $i依然是一个整型. 取模运算的结果不一样是因为php在对数值取模运算时会把浮点数转换为整型再取模(这点就不如js了,js是可以对浮点取模运算地~) 所以本地32位系统运行的其实是: ((int) $i) % 4 即 512559680 % 4 解决方法 : 最后为了保持与其他平台的一致,强制在64系统也”溢出” : ($i &#38; 0xFFFFFFFF) % 4 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; php也是一个比较无厘头的东西~]]></description>
			<content:encoded><![CDATA[<p>今天把一直本地测试的php程序放到外网的机器跑(64位系统),没想到一个纯算数值的算法竟然得到不一样的结果,最后锁定在一个求模的操作上:$i % 4, $i在本地和server上打印出来都是434807526976, 但是求出来的结果却不一样~</p>
<p>原因是:<br />
php的整型最大值为2147483647(32位系统上), <strong>当数值赋值超过这个最大值时,变量便自动成为浮点型</strong>. 所以虽然打印出来一样,但本地打印的是一个是浮点型的$i,而server上是64位系统,整型最大值达到9223372036854775807  &#8230;. $i依然是一个整型.</p>
<p>取模运算的结果不一样是因为<strong>php在对数值取模运算时会把浮点数转换为整型再取模</strong>(这点就不如js了,js是可以对浮点取模运算地~)</p>
<p>所以本地32位系统运行的其实是: ((int) $i) % 4 即 512559680 % 4</p>
<p>解决方法 : 最后为了保持与其他平台的一致,强制在64系统也”溢出” : ($i &amp; 0xFFFFFFFF) % 4</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>php也是一个比较无厘头的东西~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/03/29/1046.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个php应用最开始一般会做的事</title>
		<link>http://bluehua.org/2010/03/13/1013.html</link>
		<comments>http://bluehua.org/2010/03/13/1013.html#comments</comments>
		<pubDate>Sat, 13 Mar 2010 14:53:53 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1013</guid>
		<description><![CDATA[OK,php回顾之旅开始~ 检查PHP版本,一般发行版软件会这么做 //wordpress if ( version_compare( '4.3', phpversion(), '>' ) ) { //MediaWiki # Check for PHP 5 if ( !function_exists( 'version_compare' ) &#124;&#124; version_compare( phpversion(), '5.0.0' ) < 0 检查对性能或者安全有影响的配置项 //wordpress 尝试设置内存限制 @ini_set('memory_limit', WP_MEMORY_LIMIT); //MediaWiki if ( ini_get( 'register_globals' ) ) { //....如果自动全局变量下面将检查是否存在有害的参数 @ini_set( 'allow_url_fopen', 0 ); # For security 定义有用的常量 //wordpress //定义根目录 define( [...]]]></description>
			<content:encoded><![CDATA[<p>OK,php回顾之旅开始~</p>
<ul>
<li>检查PHP版本,一般发行版软件会这么做
<pre>
//wordpress
if ( version_compare( '4.3', phpversion(), '>' ) ) {
//MediaWiki
# Check for PHP 5
if ( !function_exists( 'version_compare' )
	|| version_compare( phpversion(), '5.0.0' ) < 0
</pre>
</li>
<li>检查对性能或者安全有影响的配置项<br/>
<pre>
//wordpress 尝试设置内存限制
@ini_set('memory_limit', WP_MEMORY_LIMIT);
</pre>
<pre>
//MediaWiki
if ( ini_get( 'register_globals' ) ) {
//....如果自动全局变量下面将检查是否存在有害的参数

@ini_set( 'allow_url_fopen', 0 ); # For security
</pre>
</li>
<li>定义有用的常量<br/>
<pre>
//wordpress
//定义根目录
define( 'ABSPATH', dirname(__FILE__) . '/' );
//定义语言, 有时会也会根据用户的语言设置初始化
define ('WPLANG', 'zh_CN');
</pre>
</li>
<li>针对不同平台,不同httpd软件的兼容代码,一般发行版软件会做
<pre>
//wordpress,针对iis的兼容代码
// IIS Mod-Rewrite
	if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
		$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
	}
</pre>
</li>
<li>初始化用于debug或者profile的函数,强大与否并不重要,但是没有是灰常不专业的...
<pre>
//wordpress
if ( defined('WP_DEBUG') &#038;&#038; WP_DEBUG ) {
....
</pre>
</li>
<li>加载通用的库文件或者框架
<pre>
require (ABSPATH . WPINC . '/functions.php');
</pre>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/03/13/1013.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wordpress plugin:搜索引擎关键词高亮</title>
		<link>http://bluehua.org/2009/07/22/333.html</link>
		<comments>http://bluehua.org/2009/07/22/333.html#comments</comments>
		<pubDate>Wed, 22 Jul 2009 15:14:30 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=333</guid>
		<description><![CDATA[下载地址更新 2009.11.8 http://wordpress.org/extend/plugins/keywords-highlight-tool/ &#8212;&#8212;&#8212;- 由于blog的访客多来自搜索引擎,所以关键词高亮会大大的增强访客的浏览体验,帮助访客快速定位感兴趣的内容. 类似插件已有很多,但俺绝不是再造普通的轮子,一定要用浏览器兼容性最好的插件,没有就自己搞.. 现存插件的实现方式有两种,一种用php在后端实现,另一种用js在前端实现. php实现高亮,浏览器兼容性最好,但是有两个问题: 1.效率问题,不如用js实现,将压力分到前端; 2.不支持cache类插件,当然这个问题可以通过hack cache插件解决,但是不可取. js实现高亮: 比较理想的实现方法,搜到一篇文章叫也谈Wordpress关键词高亮 里面讲到用js高亮关键词,但是中文gb转码使用了vbscript,所以仅支持ie浏览器 于是用自己的想法简单实现了一下这个功能, 点击搜索测试 第一个结果就应该是了 screenshot: 跟上面提到插件的主要不同点: 改进了高亮的实现方法,仅替换元素的text节点,防止造成元素事件失效 判断如果不是外链过来的访客将不加载高亮的js脚本 百度链接过来,中文gb转码时使用php后台转码,兼容所有主流浏览器 目前仅添加了对google,yahoo,baidu三个搜索引擎的支持,如果想支持更多,自行修改highlight.js即可 插件下载点这里]]></description>
			<content:encoded><![CDATA[<p>下载地址更新 2009.11.8<br />
<a href="http://wordpress.org/extend/plugins/keywords-highlight-tool/">http://wordpress.org/extend/plugins/keywords-highlight-tool/</a><br />
&#8212;&#8212;&#8212;-<br />
由于blog的访客多来自搜索引擎,所以关键词高亮会大大的增强访客的浏览体验,帮助访客快速定位感兴趣的内容.</p>
<p>类似插件已有很多,但俺绝不是再造普通的轮子,一定要用浏览器兼容性最好的插件,没有就自己搞..</p>
<p>现存插件的实现方式有两种,一种用php在后端实现,另一种用js在前端实现.</p>
<p>php实现高亮,浏览器兼容性最好,但是有两个问题:</p>
<p>1.效率问题,不如用js实现,将压力分到前端; 2.不支持cache类插件,当然这个问题可以通过hack cache插件解决,但是不可取.</p>
<p>js实现高亮:</p>
<p>比较理想的实现方法,搜到一篇文章叫<a href="http://www.jefflei.com/post/1041.html" target="_blank">也谈Wordpress关键词高亮</a> 里面讲到用js高亮关键词,但是中文gb转码使用了vbscript,所以仅支持ie浏览器</p>
<p>于是用自己的想法简单实现了一下这个功能, <a href="http://www.google.cn/search?hl=zh-CN&amp;rlz=1B3GGGL_zh-CNCN330CN331&amp;newwindow=1&amp;q=ajax+document+write+%E6%9D%8E%E5%AE%81+%E5%86%85%E8%81%94%E8%84%9A%E6%9C%AC+%E8%84%9A%E6%9C%AC&amp;btnG=Google+%E6%90%9C%E7%B4%A2" target="_blank">点击搜索测试</a> 第一个结果就应该是了<img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/char/icon_lol.gif" border="0" alt="" /></p>
<p>screenshot:</p>
<p><a href="http://bluehua.org/wp-content/uploads/2009/07/2009-7-21-21-48-56.png"><img class="alignnone size-full wp-image-336" title="2009-7-21-21-48-56" src="http://bluehua.org/wp-content/uploads/2009/07/2009-7-21-21-48-56.png" alt="2009-7-21-21-48-56" width="565" height="518" /></a></p>
<p>跟上面提到插件的主要不同点:</p>
<ul>
<li>改进了高亮的实现方法,仅替换元素的text节点,防止造成元素事件失效</li>
<li>判断如果不是外链过来的访客将不加载高亮的js脚本</li>
<li>百度链接过来,中文gb转码时使用php后台转码,兼容所有主流浏览器</li>
</ul>
<p>目前仅添加了对google,yahoo,baidu三个搜索引擎的支持,如果想支持更多,自行修改highlight.js即可</p>
<p><a href="http://sites.google.com/site/sharemyidea09/wordpress-keywords-highlight-tool" target="_blank">插件下载点这里</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2009/07/22/333.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>偶的又一wp插件:超级表情</title>
		<link>http://bluehua.org/2008/11/09/106.html</link>
		<comments>http://bluehua.org/2008/11/09/106.html#comments</comments>
		<pubDate>Sun, 09 Nov 2008 08:33:42 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=106</guid>
		<description><![CDATA[10.16 2011更新，兼容至wordpress 3.2.1，修正标签不能切换 下载x-emotions_0_1_4 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 8.29 2009 更新一下,没想到还有同学在下载这个东西哈哈~ 最近加了一套柏夫表情,发现图片大小不一样会有错位的问题,修正一下 效果就看我现在用的就好了~ 下载:x-emotions_0_1_3 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 回复andy同学:如何自定义框的高度 请下载下面的样式文件 style.css 用记事本打开此文件 #xemotion_dialog_wraper&#123; width:100%; height:400px;/*把这个高度改成想要的高度*/ position:absolute; text-align:left; &#125; 然后传到插件的img目录覆盖原文件即可 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 原来俺的emotion 一直都是拼错的,少了个c &#8212;&#8212;&#8212;&#8212;&#62;emoticons &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 有同学反映评论页没有生效,请确定一下评论框textarea元素的id是否为&#8217;comment&#8217;,是否安装了其他评论编辑插件 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 更新到0.1.2 修正Maria同学提交的bug 为什么除了第一次，以后再用表情的分类都是乱码？ 页面里没有指明编码方式,修正了~ 下载:x-emotions_0_1_2 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 更新一下:修正了 伊迭 同学反映的两个bug\ 出现Fatal error: require_once() [function.require]: Failed opening required ‘../../../wp-load.php’ (include_path=’.:/usr/local/php5/lib/php’) in ……dialog_for_comment.php on line 69 在你这显示正常，在我那就掉位了…显示不全 几个浏览器都试遍了，就Opera好点…. [...]]]></description>
			<content:encoded><![CDATA[<p>10.16 2011更新，兼容至wordpress 3.2.1，修正标签不能切换</p>
<p>下载<a href='http://bluehua.org/wp-content/uploads/2008/11/x-emotions_0_1_41.zip'>x-emotions_0_1_4</a><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
8.29 2009<br />
更新一下,没想到还有同学在下载这个东西哈哈~<br />
最近加了一套柏夫表情,发现图片大小不一样会有错位的问题,修正一下<br />
效果就看我现在用的就好了~</p>
<p>下载:<a href='http://bluehua.org/wp-content/uploads/2008/11/x-emotions_0_1_3.zip'>x-emotions_0_1_3</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>回复andy同学:如何自定义框的高度</p>
<p>请下载下面的样式文件</p>
<p><a href="http://bluehua.org/wp-content/uploads/2008/11/style.css">style.css</a></p>
<p>用记事本打开此文件</p>

<div class="wp_syntax"><div class="code overflow"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#xemotion_dialog_wraper</span><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;">100</span>%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #808080; font-style: italic;">/*把这个高度改成想要的高度*/</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>然后传到插件的img目录覆盖原文件即可<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>原来俺的emotion 一直都是拼错的<img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/daola/dora_jianzha.png" border="0" alt="" />,少了个c<br />
&#8212;&#8212;&#8212;&#8212;&gt;emoticons<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>有同学反映评论页没有生效,请确定一下评论框textarea元素的id是否为&#8217;comment&#8217;,是否安装了其他评论编辑插件</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>更新到0.1.2</p>
<p>修正Maria同学提交的bug</p>
<ul>
<li>为什么除了第一次，以后再用表情的分类都是乱码？</li>
</ul>
<p><img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/daola/dora_jianzha.png" border="0" alt="" />页面里没有指明编码方式,修正了~</p>
<p>下载:<a href="http://bluehua.org/wp-content/uploads/2008/11/x-emotions_0_1_2.rar">x-emotions_0_1_2</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>更新一下:修正了<span class="comment_author"> <cite><a rel="external nofollow" href="http://www.yidie.org/">伊迭</a></cite></span> 同学反映的两个bug\</p>
<ul>
<li>出现Fatal error: require_once() [function.require]: Failed opening required ‘../../../wp-load.php’ (include_path=’.:/usr/local/php5/lib/php’) in ……dialog_for_comment.php on line 69</li>
<li>在你这显示正常，在我那就掉位了…显示不全<br />
几个浏览器都试遍了，就Opera好点….</li>
</ul>
<p>0.1.1版本:<a href="http://bluehua.org/wp-content/uploads/2008/11/x-emotions_0_1_11.rar">x-emotions_0_1_1</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>周末很无聊，写日志很无聊，额，于是写了一个插件：x-emotions</p>
<p><img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/maomao/11.gif" border="0" alt="" />，啊哈哈哈哈，想贴就贴～</p>
<p>下载：　<a href="http://bluehua.org/wp-content/uploads/2008/11/x-emotions_0_1.rar">x-emotions_0_1</a></p>
<p>此插件最大的优点就是：可以添加多套表情，只要在表情目录新建一文件夹把新表情传到目录即可</p>
<p>安装时注意：里面的emotions文件夹的权限最好为777，cache文件要写到此目录</p>
<p>使用说明：</p>
<p>添加新表情：在插件的emotions目录新建一个目录（英文）然后把表情图片传到此目录，如果需要给此套新表情起个名字，则把名字写到一个utf-8编码的名为name.txt的文本文件里，并把此文件传到对应的表情目录．</p>
<p><strong><span style="color: #000000;">注意</span></strong>：添加新表情之后必须删除emotions目录下的名字为&#8217;cache_for_editor.php&#8217;和&#8217;cache_for_comment.php&#8217;两个缓存文件，重建缓存之后才能看到新传的表情</p>
<p>自定义变量：</p>
<p>x-emotions.php 里的</p>
<p>$blue_emotions_enable_in_comments = true</p>
<p>//是否在留言启用此插件，默认为true，启用</p>
<p>screenshot</p>
<p>－－－－－－－－－－－－－－－－－－－－－－－－－</p>
<p>在编辑器使用</p>
<p><a href="http://bluehua.org/wp-content/uploads/2008/11/snag-0043.png"><img class="alignnone size-medium wp-image-107" title="snag-0043" src="http://bluehua.org/wp-content/uploads/2008/11/snag-0043-300x104.png" alt="" width="300" height="104" /></a></p>
<p>在编辑器使用时的对话框</p>
<p><a href="http://bluehua.org/wp-content/uploads/2008/11/snag-0042.png"><img class="alignnone size-medium wp-image-110" title="snag-0042" src="http://bluehua.org/wp-content/uploads/2008/11/snag-0042-300x253.png" alt="" width="300" height="253" /></a></p>
<p>在留言使用</p>
<p><a href="http://bluehua.org/wp-content/uploads/2008/11/snag-0040.png"><img class="alignnone size-medium wp-image-108" title="snag-0040" src="http://bluehua.org/wp-content/uploads/2008/11/snag-0040-249x300.png" alt="" width="249" height="300" /></a></p>
<p>在留言使用时的界面</p>
<p><a href="http://bluehua.org/wp-content/uploads/2008/11/snag-0041.png"><img class="alignnone size-medium wp-image-109" title="snag-0041" src="http://bluehua.org/wp-content/uploads/2008/11/snag-0041-300x124.png" alt="" width="300" height="124" /></a></p>
<p><a href="http://bluehua.org/wp-content/uploads/2008/11/snag-0040.png"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2008/11/09/106.html/feed</wfw:commentRss>
		<slash:comments>85</slash:comments>
		</item>
		<item>
		<title>无聊写个wp插件:给日志添加当天天气-blueweather</title>
		<link>http://bluehua.org/2008/09/01/61.html</link>
		<comments>http://bluehua.org/2008/09/01/61.html#comments</comments>
		<pubDate>Sun, 31 Aug 2008 16:38:17 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=61</guid>
		<description><![CDATA[北京:晴,19.5℃,西西北风1级 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 又改了一下,直接使用class-snoopy.php~~ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 这个周末有点无聊,本来打算看看c++,给手机搞个可以同步时间的软件,但是看了半天,symbian远比我想象的麻烦,装了开发环境,但是一编译vc就挂了~ 逛了一下wordpress中文站,发现有个想法不错,就是在日志编辑器直接插入当天的天气,遂实现之~~ 实现过程很简单:通过ip查询地名,然后根据地名获取天气. 这个版本需要curl库的支持,但是装curl的虚拟主机好像也不是很多(shit,竟然不给装soap~),有时间改个fsocket版的再发~~]]></description>
			<content:encoded><![CDATA[<p>北京:晴,19.5℃,西西北风1级</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>又改了一下,直接使用class-snoopy.php~~</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>这个周末有点无聊,本来打算看看c++,给手机搞个可以同步时间的软件,但是看了半天,symbian远比我想象的麻烦,装了开发环境,但是一编译vc就挂了~</p>
<p>逛了一下wordpress中文站,发现有个想法不错,就是在日志编辑器直接插入当天的天气,遂实现之~~</p>
<p>实现过程很简单:通过ip查询地名,然后根据地名获取天气.</p>
<p>这个版本需要curl库的支持,但是装curl的虚拟主机好像也不是很多(shit,竟然不给装soap~),有时间改个fsocket版的再发~~</p>
<div id="attachment_60" class="wp-caption alignnone" style="width: 510px"><a href="http://bluehua.org/wp-content/uploads/2008/09/snag-0017.png"><img class="size-full wp-image-60" title="snag-0017" src="http://bluehua.org/wp-content/uploads/2008/09/snag-0017.png" alt="blueweather" width="500" height="104" /></a><p class="wp-caption-text">blueweather</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2008/09/01/61.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 2.137 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-05 02:15:26 -->

