<?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>Davy&#039;s Blog</title>
	<atom:link href="http://blog.hao909.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hao909.com</link>
	<description>Nothing is impossible­ for a willing heart.</description>
	<lastBuildDate>Thu, 29 Jul 2010 11:54:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ThinkPHP中forward和redirect的区别</title>
		<link>http://blog.hao909.com/thinkphp%e4%b8%adforward%e5%92%8credirect%e7%9a%84%e5%8c%ba%e5%88%ab/</link>
		<comments>http://blog.hao909.com/thinkphp%e4%b8%adforward%e5%92%8credirect%e7%9a%84%e5%8c%ba%e5%88%ab/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 11:54:19 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[PHP Script]]></category>
		<category><![CDATA[thinkphp]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=458</guid>
		<description><![CDATA[ThinkPHP中forward和redirect的区别在那里呢？
首先看代码注释：
forward: 执行某个Action操作(隐含跳转) 支持指定模块和延时执行
redirect: Action跳转(URL重定向) 支持指定模块和延时跳转
其次看代码组织，二者的行为是不同的:
forward:

        if(is_array($action)) {
            //通过类似 array(&#38;$module,$action)的方式调用
            call_user_func($action);
        }else {
        [...]]]></description>
		<wfw:commentRss>http://blog.hao909.com/thinkphp%e4%b8%adforward%e5%92%8credirect%e7%9a%84%e5%8c%ba%e5%88%ab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to disable/enable an element with jQuery</title>
		<link>http://blog.hao909.com/how-to-disableenable-an-element-with-jquery/</link>
		<comments>http://blog.hao909.com/how-to-disableenable-an-element-with-jquery/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 16:18:42 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[attribute]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=455</guid>
		<description><![CDATA[Sometimes you need to disable or enable some elements in your document and jQuery makes this task easy. All you have to do is to set disabled attribute to &#8220;disabled&#8221;. 
Example:

// To disable
$('.someElement').attr('disabled', 'disabled');

In order to enable any disabled element you need to set the disabled attribute to empty string or remove it entirely like [...]]]></description>
		<wfw:commentRss>http://blog.hao909.com/how-to-disableenable-an-element-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Equivalent of PHP’s trim function</title>
		<link>http://blog.hao909.com/javascript-equivalent-of-php-trim-function/</link>
		<comments>http://blog.hao909.com/javascript-equivalent-of-php-trim-function/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 15:58:18 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[string function]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=452</guid>
		<description><![CDATA[Trim function in PHP can remove whitespace from the beginning and end of a string. 
Javascript do not have this function, but is easy to made one.

// remove space in a string
function trim(str)
{
	if(!str &#124;&#124; typeof str != 'string')
		return null;

	return str.replace('/^\s+&#124;\s+$/g', '');
}

]]></description>
		<wfw:commentRss>http://blog.hao909.com/javascript-equivalent-of-php-trim-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Equivalent of PHP&#8217;s explode() and implode()</title>
		<link>http://blog.hao909.com/javascript-equivalent-of-phps-explode-and-implode/</link>
		<comments>http://blog.hao909.com/javascript-equivalent-of-phps-explode-and-implode/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 03:21:23 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[code string]]></category>
		<category><![CDATA[php code]]></category>
		<category><![CDATA[php implode]]></category>
		<category><![CDATA[string code]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=448</guid>
		<description><![CDATA[Do you know javascript has equivalent functions as php&#8217;s explode() and implode(). 
Let&#8217;s say we have a string:

$string = 'aa:bb:cc';

We want to break down each number into an array called $num_array.
In PHP we could do this:

$explode_array = explode(':', $string);

The PHP implode function would produce the following:

$explode_array[0] = 13
$explode_array[1] = 42
$explode_array[2] = 43
$explode_array[3] = 56

In Javascript, [...]]]></description>
		<wfw:commentRss>http://blog.hao909.com/javascript-equivalent-of-phps-explode-and-implode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ThinkPHP上传类库的Bug修复</title>
		<link>http://blog.hao909.com/thinkphp%e4%b8%8a%e4%bc%a0%e7%b1%bb%e5%ba%93%e7%9a%84bug%e4%bf%ae%e5%a4%8d/</link>
		<comments>http://blog.hao909.com/thinkphp%e4%b8%8a%e4%bc%a0%e7%b1%bb%e5%ba%93%e7%9a%84bug%e4%bf%ae%e5%a4%8d/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 01:48:54 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[thinkphp]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=438</guid>
		<description><![CDATA[最近开发网站用到了ThinkPHP 2.0的上传类库， 用来实现一个图片上传功能。
使用过程中发现，如果开启了子目录创建方式，则会出现一些问题：
public $autoSub = true;
1. 无法生成缩略图, 此问题的修复办法如下, 在 UploadFile.class.php 中找到 line#145

         if ($this-&#62;thumb) {
            // 生成图像缩略图
            import(&#34;@.ORG.Image&#34;);
        [...]]]></description>
		<wfw:commentRss>http://blog.hao909.com/thinkphp%e4%b8%8a%e4%bc%a0%e7%b1%bb%e5%ba%93%e7%9a%84bug%e4%bf%ae%e5%a4%8d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mass Replace String use MySQL REPLACE function</title>
		<link>http://blog.hao909.com/mass-replace-string-use-mysql-replace-function/</link>
		<comments>http://blog.hao909.com/mass-replace-string-use-mysql-replace-function/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 12:55:05 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[code mass]]></category>
		<category><![CDATA[database table]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[sql query]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=435</guid>
		<description><![CDATA[Since i changed the path for a friend&#8217;s blog,  i need update the files and images path URL in all previous posts.
The best way i found is use MySQL REPLACE function to replace string in hundreds of records. Only need 1 minute. 
Here is the SQL query to replace string in database table:

UPDATE table_name [...]]]></description>
		<wfw:commentRss>http://blog.hao909.com/mass-replace-string-use-mysql-replace-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用正则表达式进行ThinkPHP的自动验证</title>
		<link>http://blog.hao909.com/%e4%bd%bf%e7%94%a8%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e8%bf%9b%e8%a1%8cthinkphp%e7%9a%84%e8%87%aa%e5%8a%a8%e9%aa%8c%e8%af%81/</link>
		<comments>http://blog.hao909.com/%e4%bd%bf%e7%94%a8%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e8%bf%9b%e8%a1%8cthinkphp%e7%9a%84%e8%87%aa%e5%8a%a8%e9%aa%8c%e8%af%81/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 13:09:21 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[thinkphp]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=433</guid>
		<description><![CDATA[ThinkPHP的自动验证机制是为了进行表单数据验证，验证可以支持function、 callback、confirm、equal、unique和regex，这里要讲的是使用正则表达式进行验证。
一般我们见的比较多的是设置规则为require、email之类的，其实这些本身也是属于正则表达式验证方式，只是系统内置定义了一些常用的正则表达式而已。这些内置的正则表达式的定义可以参考model类的regex方法，内置支持的正则定义包括：
require 字段必须、email 邮箱、url URL地址、currency 货币、number 数字、zip 邮编、integer 整数、double 浮点数、english 英文字母，但是并不局限于这些正则规则的，我们完全可以直接在验证规则里面使用正则表达式进行定义，这样我们可以凭借强大的正则表达式来进行表单字段验证，例如：
array(‘name’,&#8217;/^[a-z]\w{3,}$/i’,&#8217;名字不符合要求！’);
array(‘password’,&#8217;/^[a-z]\w{6,30}$/i’,&#8217;密码不符合要求！’);
array(‘account’,&#8217;/^[A-Za-z]+$/’,&#8217;账号必须使用英文！’);
附上一些表单验证中比较常用的正则表达式写法：
匹配中文字符的正则表达式： [\u4e00-\u9fa5]
匹配双字节字符(包括汉字在内)：[^\x00-\xff]
匹配Email地址的正则表达式：\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
匹配网址URL的正则表达式：[a-zA-z]+://[^\s]*
匹配帐号是否合法(字母开头，允许5-16字节，允许字母数字下划线)：^[a-zA-Z][a-zA-Z0-9_]{4,15}$
匹配国内电话号码：\d{3}-\d{8}&#124;\d{4}-\d{7}
匹配中国邮政编码：[1-9]\d{5}(?!\d)
匹配ip地址：\d+\.\d+\.\d+\.\d+
匹配特定数字：
^[1-9]\d*$　 　 //匹配正整数
^-[1-9]\d*$ 　 //匹配负整数
^-?[1-9]\d*$　　 //匹配整数
^[1-9]\d*&#124;0$　 //匹配非负整数（正整数 + 0）
^-[1-9]\d*&#124;0$　　 //匹配非正整数（负整数 + 0）
^[1-9]\d*\.\d*&#124;0\.\d*[1-9]\d*$　　 //匹配正浮点数
^-([1-9]\d*\.\d*&#124;0\.\d*[1-9]\d*)$　 //匹配负浮点数
^-?([1-9]\d*\.\d*&#124;0\.\d*[1-9]\d*&#124;0?\.0+&#124;0)$　 //匹配浮点数
^[1-9]\d*\.\d*&#124;0\.\d*[1-9]\d*&#124;0?\.0+&#124;0$　　 //匹配非负浮点数（正浮点数 + 0）
^(-([1-9]\d*\.\d*&#124;0\.\d*[1-9]\d*))&#124;0?\.0+&#124;0$　　//匹配非正浮点数（负浮点数 + 0）
匹配特定字符串：
^[A-Za-z]+$　　//匹配由26个英文字母组成的字符串
^[A-Z]+$　　//匹配由26个英文字母的大写组成的字符串
^[a-z]+$　　//匹配由26个英文字母的小写组成的字符串
^[A-Za-z0-9]+$　　//匹配由数字和26个英文字母组成的字符串
^\w+$　　//匹配由数字、26个英文字母或者下划线组成的字符串
]]></description>
		<wfw:commentRss>http://blog.hao909.com/%e4%bd%bf%e7%94%a8%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e8%bf%9b%e8%a1%8cthinkphp%e7%9a%84%e8%87%aa%e5%8a%a8%e9%aa%8c%e8%af%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ThinkPHP的动态数据查询方法</title>
		<link>http://blog.hao909.com/thinkphp%e7%9a%84%e5%8a%a8%e6%80%81%e6%95%b0%e6%8d%ae%e6%9f%a5%e8%af%a2%e6%96%b9%e6%b3%95/</link>
		<comments>http://blog.hao909.com/thinkphp%e7%9a%84%e5%8a%a8%e6%80%81%e6%95%b0%e6%8d%ae%e6%9f%a5%e8%af%a2%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 13:07:46 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[thinkphp]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=431</guid>
		<description><![CDATA[ThinkPHP提供了数据的动态查询方法，可以简化你的查询代码，例如：
$User->where(‘name=”ThinkPHP”‘)->find();
可以简化为：
$User->getByName(‘ThinkPHP’);
$User->where(‘email=”thinkphp@qq.com”‘)->find();
可以简化为：
$User->getByEmail(‘thinkphp@qq.com’);
getBy**** 方法里面的**** 会转换成小写的字段名，如果字段不存在，就会出错。
如果你的字段名是user_id ，那么查询方法应该写成：
$User->getByUserId(5);
UserId 会被解析成为数据库的user_id字段，这点需要注意，以免引起不必要的麻烦。
目前尚不支持，对多个字段的动态查询。
]]></description>
		<wfw:commentRss>http://blog.hao909.com/thinkphp%e7%9a%84%e5%8a%a8%e6%80%81%e6%95%b0%e6%8d%ae%e6%9f%a5%e8%af%a2%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>避免ThinkPHP URL目录过深的技巧</title>
		<link>http://blog.hao909.com/%e9%81%bf%e5%85%8dthinkphp-url%e7%9b%ae%e5%bd%95%e8%bf%87%e6%b7%b1%e7%9a%84%e6%8a%80%e5%b7%a7/</link>
		<comments>http://blog.hao909.com/%e9%81%bf%e5%85%8dthinkphp-url%e7%9b%ae%e5%bd%95%e8%bf%87%e6%b7%b1%e7%9a%84%e6%8a%80%e5%b7%a7/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 13:06:11 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[thinkphp]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=429</guid>
		<description><![CDATA[按照ThinkPHP的默认URL模式，通常是：
http://serverName/模块名/操作名/变量1/值1/变量2/值2…
很多人担心这样的URL会导致目录层次过深，而且由于这样的URL改变了当前的相对路径，所以如果不注意写法，经常会导致JS和CSS加载不到。问题就在于这个”/”，这两个问题都可以通过一个小技巧解决，而且不影响你的开发，只需要在项目配置文件中设置
‘URL_PATHINFO_DEPR’=>’-&#8217;,
这个配置默认值是”/” 我们更改为”-”
配置修改以后，上面的URL地址就可以变成：
http://serverName/模块名-操作名-变量1-值1-变量2-值2…
不过要注意的是，模板里面的链接地址最好是用U方法动态生成的，而不是固定写死的，否则模板会有一定的修改工作。
]]></description>
		<wfw:commentRss>http://blog.hao909.com/%e9%81%bf%e5%85%8dthinkphp-url%e7%9b%ae%e5%bd%95%e8%bf%87%e6%b7%b1%e7%9a%84%e6%8a%80%e5%b7%a7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ThinkPHP判断当前操作的请求类型</title>
		<link>http://blog.hao909.com/thinkphp%e5%88%a4%e6%96%ad%e5%bd%93%e5%89%8d%e6%93%8d%e4%bd%9c%e7%9a%84%e8%af%b7%e6%b1%82%e7%b1%bb%e5%9e%8b/</link>
		<comments>http://blog.hao909.com/thinkphp%e5%88%a4%e6%96%ad%e5%bd%93%e5%89%8d%e6%93%8d%e4%bd%9c%e7%9a%84%e8%af%b7%e6%b1%82%e7%b1%bb%e5%9e%8b/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 13:04:16 +0000</pubDate>
		<dc:creator>greenhawk</dc:creator>
				<category><![CDATA[thinkphp]]></category>

		<guid isPermaLink="false">http://blog.hao909.com/?p=427</guid>
		<description><![CDATA[在很多情况下面，我们需要判断当前操作的请求类型是GET POST 甚至是PUT DELETE，一方面可以针对作出不同的逻辑处理，另外一方面有些情况下面需要验证安全性，过滤不安全的请求。
TP的Action类内置了一些判断方法用于判断请求类型，包括：
isGet 是否是GET提交
isPost 是否是POST提交
isPut 是否是PUT提交
isDelete 是否是DELETE提交
isHead 是否是HEAD提交
使用举例如下：

class UserAction extends Action{
  public function update(){
    if ($this-&#62;isPost()){
      $User = M(‘User’);
      $User-&#62;create();
      $User-&#62;save();
      $this-&#62;success(‘保存完成’);
    } else {
   [...]]]></description>
		<wfw:commentRss>http://blog.hao909.com/thinkphp%e5%88%a4%e6%96%ad%e5%bd%93%e5%89%8d%e6%93%8d%e4%bd%9c%e7%9a%84%e8%af%b7%e6%b1%82%e7%b1%bb%e5%9e%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
