<?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>周帆的Web实验室 &#187; 程序开发</title>
	<atom:link href="http://www.raychou.com/chou/categories/develop/feed" rel="self" type="application/rss+xml" />
	<link>http://www.raychou.com/chou</link>
	<description>专注PHP，关注Web相关</description>
	<lastBuildDate>Fri, 11 Jun 2010 00:29:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RaterStar更新：支持自定义鼠标悬停Title</title>
		<link>http://www.raychou.com/chou/posts/352.htm</link>
		<comments>http://www.raychou.com/chou/posts/352.htm#comments</comments>
		<pubDate>Sun, 24 Jan 2010 14:41:13 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[实验室]]></category>
		<category><![CDATA[程序开发]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[RaterStar]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/352.htm</guid>
		<description><![CDATA[RaterStar改版以后，一直拖欠着网友们一个小功能，自定义title，最近终于有时间将这个老版中就有的功能移植到了新版，并且使用起来也更加灵活方便。
使用方法请参照Demo11
相关文章

jQuery Rater Star Plugin 修正：自定义Title后无法点击星星 (3)
jQuery投票插件RaterStar顺利毕业 (25)
LinkageSelect 基于jQuery的联动下拉菜单 (7)
UCHome二次开发规范 &#8211; 不同于Manyou的开发模式 (5)
轻量级表单验证插件 jQuery.Validation (3)


本文出自周帆的Web实验室，转载时请注明作者及出处

查看原文 &#124;
已有2位网友发表了评论]]></description>
			<content:encoded><![CDATA[<p>RaterStar改版以后，一直拖欠着网友们一个小功能，自定义title，最近终于有时间将这个老版中就有的功能移植到了新版，并且使用起来也更加灵活方便。</p>
<p>使用方法请参照<a href="http://www.raychou.com/labs/rater-star/#demo11">Demo11</a></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/303.htm" title="jQuery Rater Star Plugin 修正：自定义Title后无法点击星星">jQuery Rater Star Plugin 修正：自定义Title后无法点击星星 (3)</a></li>
<li><a href="http://www.raychou.com/chou/posts/329.htm" title="jQuery投票插件RaterStar顺利毕业">jQuery投票插件RaterStar顺利毕业 (25)</a></li>
<li><a href="http://www.raychou.com/chou/posts/317.htm" title="LinkageSelect 基于jQuery的联动下拉菜单">LinkageSelect 基于jQuery的联动下拉菜单 (7)</a></li>
<li><a href="http://www.raychou.com/chou/posts/276.htm" title="UCHome二次开发规范 &#8211; 不同于Manyou的开发模式">UCHome二次开发规范 &#8211; 不同于Manyou的开发模式 (5)</a></li>
<li><a href="http://www.raychou.com/chou/posts/221.htm" title="轻量级表单验证插件 jQuery.Validation">轻量级表单验证插件 jQuery.Validation (3)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/352.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/352.htm#comments">已有2位网友发表了评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/352.htm/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP FTP Client：基于PHP的FTP客户端</title>
		<link>http://www.raychou.com/chou/posts/346.htm</link>
		<comments>http://www.raychou.com/chou/posts/346.htm#comments</comments>
		<pubDate>Sun, 08 Nov 2009 10:04:05 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[实验室]]></category>
		<category><![CDATA[程序开发]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[客户端]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/346.htm</guid>
		<description><![CDATA[半年前，曾写过一篇通过SVN Hooks实现本地SVN仓库与线上FTP服务器同步的文章《让虚拟主机也用上SVN：适用于个人的开发部署方式》，其中使用到了一个PhpFtpClient的类库，直到今天才有时间稍做了下整理，写了几个Demo，欢迎网友们提出宝贵意见以便改进。
目前已支持的功能：

目录列表
创建文件夹/文件
删除文件夹/文件（支持子文件夹）
上传文件夹/文件（支持子文件夹）
自动判断上传文件格式（ASCII/BINARY）

PhpFtpClient围观地址：http://www.raychou.com/labs/php-ftp-client/
相关文章

在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer (2)
PHP连贯接口 (0)
让虚拟主机也用上SVN：适用于个人的开发部署方式 (5)
PHP autoload与include性能比较 (3)
转战Eclipse (0)


本文出自周帆的Web实验室，转载时请注明作者及出处

查看原文 &#124;
已有1位网友发表了评论]]></description>
			<content:encoded><![CDATA[<p>半年前，曾写过一篇通过SVN Hooks实现本地SVN仓库与线上FTP服务器同步的文章<a href="http://www.raychou.com/chou/posts/319.htm" title="让虚拟主机也用上SVN：适用于个人的开发部署方式">《让虚拟主机也用上SVN：适用于个人的开发部署方式》</a>，其中使用到了一个PhpFtpClient的类库，直到今天才有时间稍做了下整理，写了几个Demo，欢迎网友们提出宝贵意见以便改进。</p>
<p>目前已支持的功能：</p>
<ul>
<li>目录列表</li>
<li>创建文件夹/文件</li>
<li>删除文件夹/文件（支持子文件夹）</li>
<li>上传文件夹/文件（支持子文件夹）</li>
<li>自动判断上传文件格式（ASCII/BINARY）</li>
</ul>
<p>PhpFtpClient围观地址：<a href="http://www.raychou.com/labs/php-ftp-client/">http://www.raychou.com/labs/php-ftp-client/</a></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/356.htm" title="在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer">在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer (2)</a></li>
<li><a href="http://www.raychou.com/chou/posts/334.htm" title="PHP连贯接口">PHP连贯接口 (0)</a></li>
<li><a href="http://www.raychou.com/chou/posts/319.htm" title="让虚拟主机也用上SVN：适用于个人的开发部署方式">让虚拟主机也用上SVN：适用于个人的开发部署方式 (5)</a></li>
<li><a href="http://www.raychou.com/chou/posts/299.htm" title="PHP autoload与include性能比较">PHP autoload与include性能比较 (3)</a></li>
<li><a href="http://www.raychou.com/chou/posts/207.htm" title="转战Eclipse">转战Eclipse (0)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/346.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/346.htm#comments">已有1位网友发表了评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/346.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP连贯接口</title>
		<link>http://www.raychou.com/chou/posts/334.htm</link>
		<comments>http://www.raychou.com/chou/posts/334.htm#comments</comments>
		<pubDate>Tue, 16 Jun 2009 01:35:00 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[连贯接口]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/334.htm</guid>
		<description><![CDATA[什么是连贯接口？经常用jQuery的朋友一定对下面的代码非常熟悉：

$&#40;'div'&#41;.find&#40;'element'&#41;.hide&#40;&#41;;

像上面这样，在一个方法后直接调用另一个同级方法，我们习惯上称其连贯接口。
连贯接口有什么好处呢？拿我们常用的工厂模式来举例：

$sql= new Joy_Db_SqlBuilder&#40;&#41;;
$sql-&#38;gt;select&#40;&#41;;
$sql-&#38;gt;table&#40;'test'&#41;;
$sql-&#38;gt;where&#40;'id' , '=' , '1'&#41;;

换成连贯接口来实现的代码会是怎样呢？

$sql= new Joy_Db_SqlBuilder&#40;&#41;;
$sql-&#38;gt;select&#40;&#41;
    -&#38;gt;table&#40;'test'&#41;
    -&#38;gt;where&#40;'id' , '=' , '1'&#41;;

可以看到在上面的代码中，相对以往的工厂模式的写法，使用连贯接口能稍微节省一些代码量，并且，代码逻辑性也更强。
如何实现连贯接口呢？这里我引用JoyPHP中的一段代码

class Joy_Db_SqlBuilder &#123;
    /**
     * select方法
     * 
     * @return Joy_Db_SqlBuilder
     */
    public [...]]]></description>
			<content:encoded><![CDATA[<p>什么是连贯接口？经常用jQuery的朋友一定对下面的代码非常熟悉：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'element'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>像上面这样，在一个方法后直接调用另一个同级方法，我们习惯上称其连贯接口。</p>
<p>连贯接口有什么好处呢？拿我们常用的工厂模式来举例：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$sql</span><span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Joy_Db_SqlBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>select<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>where<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'='</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>换成连贯接口来实现的代码会是怎样呢？</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$sql</span><span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Joy_Db_SqlBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>select<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>table<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>where<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'='</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>可以看到在上面的代码中，相对以往的工厂模式的写法，使用连贯接口能稍微节省一些代码量，并且，代码逻辑性也更强。</p>
<p>如何实现连贯接口呢？这里我引用JoyPHP中的一段代码</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Joy_Db_SqlBuilder <span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * select方法
     * 
     * @return Joy_Db_SqlBuilder
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> select<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;">-&amp;</span>gt<span style="color: #339933;">;</span>_args    <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'method'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">'select'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #009933; font-style: italic;">/**
     * 定义所用的表名
     *
     * @param string $name
     * @param string $alias
     * @return Joy_Db_SqlBuilder|string
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> table<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>                
        <span style="color: #666666; font-style: italic;">// @todo something</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// 返回this，实现连贯接口</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>从代码中可以看到，每个方法都返回了$this，而$this表示的正式Joy_Db_SqlBuilder的实例，因此才可以继续调用其方法。</p>
<p>连贯接口很简单，写起来也很美，但是却遇到一个棘手的问题，类似ZendStudio，Eclipse之类的IDE似乎并不支持连贯接口的自动提示？其实结局的方法也很简单，只要像上面的代码注释那样，遵循PHPDoc的代码注释规范，在@return后注明返回的对象类型，这些IDE也同样能实现自动提示。</p>
<p><img src="http://www.raychou.com/chou/wp-content/uploads/2009/06/zrtn-001p2b6df6b1-tn.jpg" style="WIDTH: 500px; HEIGHT: 204px" height="204" width="500"/></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/207.htm" title="转战Eclipse">转战Eclipse (0)</a></li>
<li><a href="http://www.raychou.com/chou/posts/356.htm" title="在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer">在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer (2)</a></li>
<li><a href="http://www.raychou.com/chou/posts/346.htm" title="PHP FTP Client：基于PHP的FTP客户端">PHP FTP Client：基于PHP的FTP客户端 (1)</a></li>
<li><a href="http://www.raychou.com/chou/posts/299.htm" title="PHP autoload与include性能比较">PHP autoload与include性能比较 (3)</a></li>
<li><a href="http://www.raychou.com/chou/posts/252.htm" title="Eclipse加速技巧一则">Eclipse加速技巧一则 (1)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/334.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/334.htm#comments">对文章内容发表评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/334.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery投票插件RaterStar顺利毕业</title>
		<link>http://www.raychou.com/chou/posts/329.htm</link>
		<comments>http://www.raychou.com/chou/posts/329.htm#comments</comments>
		<pubDate>Fri, 29 May 2009 04:07:00 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[实验室]]></category>
		<category><![CDATA[程序开发]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rater]]></category>
		<category><![CDATA[star]]></category>
		<category><![CDATA[投票]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/329.htm</guid>
		<description><![CDATA[
RaterStar是一年多前，在做三宝殿项目时开发的一个基于jQuery的投票插件，之后也得到了很多网友的关注和建议，让这个插件在一年多的时间内得以不断完善。
在实验室上线后，一直就考虑要将ReterStar加入到其中，但因为当初在写这个插件时，对jQuery并不是很熟悉，部分代码写得并不是很好，所以打算将其重写后再发布。
目前RaterStar已从Demo转移到Labs。新版的RaterStar在实现原版功能的基础上，更增加了一些实用的方法和参数，目前已经实现的功能如下：

自定义默认值
可设置是否可以更改默认值
自定义星星个数
自定义星星图片 NEW!
自定义起止值，递增步长
支持AJAX
自定义事件（目前支持点击后、AJAX请求之前，AJAX请求成功三种情况的事件触发）NEW!
自定义AJAX请求方式（POST/GET） NEW!
自定义鼠标悬停Title NEW!

更多的功能将在以后逐步完善，也欢迎大家给建议。
在线演示
相关文章

jQuery Rater Star Plugin 修正：自定义Title后无法点击星星 (3)
LinkageSelect 基于jQuery的联动下拉菜单 (7)
轻量级表单验证插件 jQuery.Validation (3)
更新 jQuery Rater Star Plugin (4)
RaterStar更新：支持自定义鼠标悬停Title (2)


本文出自周帆的Web实验室，转载时请注明作者及出处

查看原文 &#124;
已有25位网友发表了评论]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.raychou.com/chou/wp-content/uploads/2009/05/2009-05-29-130143.gif" alt="2009-05-29_130143.gif" height="44" width="253"/></p>
<p><a href="http://www.raychou.com/labs/rater-star/" target="_blank" title="jQuery Rater Star Plugin">RaterStar</a>是一年多前，在做<a href="http://www.3baodian.com/" target="_blank" title="三宝殿装修社区">三宝殿</a>项目时开发的一个基于<a href="http://www.jquery.com/" target="_blank" title="jQuery">jQuery</a>的投票插件，之后也得到了很多网友的关注和建议，让这个插件在一年多的时间内得以不断完善。</p>
<p>在<a href="http://www.raychou.com/chou/labs" title="实验室">实验室</a>上线后，一直就考虑要将ReterStar加入到其中，但因为当初在写这个插件时，对jQuery并不是很熟悉，部分代码写得并不是很好，所以打算将其重写后再发布。</p>
<p>目前RaterStar已从Demo转移到Labs。新版的RaterStar在实现原版功能的基础上，更增加了一些实用的方法和参数，目前已经实现的功能如下：</p>
<ul>
<li>自定义默认值</li>
<li>可设置是否可以更改默认值</li>
<li>自定义星星个数</li>
<li>自定义星星图片 <span style="COLOR: #ff0000; FONT-SIZE: 10px">NEW!</span></li>
<li>自定义起止值，递增步长</li>
<li>支持AJAX</li>
<li>自定义事件（目前支持点击后、AJAX请求之前，AJAX请求成功三种情况的事件触发）<span style="COLOR: #ff0000; FONT-SIZE: 10px">NEW!</span></li>
<li>自定义AJAX请求方式（POST/GET） <span style="COLOR: #ff0000; FONT-SIZE: 10px">NEW!</span></li>
<li>自定义鼠标悬停Title <span style="COLOR: #ff0000; FONT-SIZE: 10px">NEW!</span></li>
</ul>
<p>更多的功能将在以后逐步完善，也欢迎大家给建议。</p>
<p><a href="http://www.raychou.com/labs/rater-star/" target="_blank" title="RaterStar">在线演示</a></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/303.htm" title="jQuery Rater Star Plugin 修正：自定义Title后无法点击星星">jQuery Rater Star Plugin 修正：自定义Title后无法点击星星 (3)</a></li>
<li><a href="http://www.raychou.com/chou/posts/317.htm" title="LinkageSelect 基于jQuery的联动下拉菜单">LinkageSelect 基于jQuery的联动下拉菜单 (7)</a></li>
<li><a href="http://www.raychou.com/chou/posts/221.htm" title="轻量级表单验证插件 jQuery.Validation">轻量级表单验证插件 jQuery.Validation (3)</a></li>
<li><a href="http://www.raychou.com/chou/posts/194.htm" title="更新 jQuery Rater Star Plugin">更新 jQuery Rater Star Plugin (4)</a></li>
<li><a href="http://www.raychou.com/chou/posts/352.htm" title="RaterStar更新：支持自定义鼠标悬停Title">RaterStar更新：支持自定义鼠标悬停Title (2)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/329.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/329.htm#comments">已有25位网友发表了评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/329.htm/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>LinkageSelect新增AJAX方式调用数据</title>
		<link>http://www.raychou.com/chou/posts/327.htm</link>
		<comments>http://www.raychou.com/chou/posts/327.htm#comments</comments>
		<pubDate>Thu, 14 May 2009 05:08:00 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[实验室]]></category>
		<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[联动菜单]]></category>
		<category><![CDATA[LinkageSelect]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/327.htm</guid>
		<description><![CDATA[原有的两种数据调用方式都是一次性全部载入所有数据，虽然在点击菜单时切换速度快，但不适合数据量很大的情况，因此新增了第三种数据调用方式。

var options = &#123;
   ajax : './data_builder/ajax.php'
&#125;
var loc = new LinkageSelect&#40;options&#41;;
loc.bind&#40;'#demo6 .level_1'&#41;;
loc.bind&#40;'#demo6 .level_2'&#41;;
loc.bind&#40;'#demo6 .level_3'&#41;;

在ajax模式下，只有在用户选择后，才会触发事件去调用下一层数据，并有缓存，也就是说不会重复下载已经调用过的菜单项。
演示Demo6 AJAX调用数据
相关文章

LinkageSelect 基于jQuery的联动下拉菜单 (7)
GMail的小变化 (0)


本文出自周帆的Web实验室，转载时请注明作者及出处

查看原文 &#124;
已有4位网友发表了评论]]></description>
			<content:encoded><![CDATA[<p>原有的两种数据调用方式都是一次性全部载入所有数据，虽然在点击菜单时切换速度快，但不适合数据量很大的情况，因此新增了第三种数据调用方式。</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
   ajax <span style="color: #339933;">:</span> <span style="color: #3366CC;">'./data_builder/ajax.php'</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> loc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> LinkageSelect<span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
loc.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#demo6 .level_1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
loc.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#demo6 .level_2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
loc.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#demo6 .level_3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>在ajax模式下，只有在用户选择后，才会触发事件去调用下一层数据，并有缓存，也就是说不会重复下载已经调用过的菜单项。</p>
<p>演示<a href="http://www.raychou.com/labs/linkage-select/#demo6">Demo6 AJAX调用数据</a></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/317.htm" title="LinkageSelect 基于jQuery的联动下拉菜单">LinkageSelect 基于jQuery的联动下拉菜单 (7)</a></li>
<li><a href="http://www.raychou.com/chou/posts/70.htm" title="GMail的小变化">GMail的小变化 (0)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/327.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/327.htm#comments">已有4位网友发表了评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/327.htm/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>天气预报系统更新：支持自定义数据格式</title>
		<link>http://www.raychou.com/chou/posts/321.htm</link>
		<comments>http://www.raychou.com/chou/posts/321.htm#comments</comments>
		<pubDate>Sun, 10 May 2009 16:19:34 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[实验室]]></category>
		<category><![CDATA[天气预报]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/321.htm</guid>
		<description><![CDATA[天气预报系统一直都有很多网友在使用和关注，我也一直没有放弃更新。但一直因为原来的代码部署方式过于麻烦而一直没有做大的改进。在部署了新的开发方式后，一方面正好可以测试这套方案的健壮性，另一方面也把以前网友们提出的建议实现。
这次更新最大的改进是支持自定义数据格式，用户可以根据自己的需要选择数据格式，输出的条数，以及是否只显示雨雪天气预报。

数据格式：目前提供了html,rss,ical三种格式输出，计划中还要提供json，以及方便手机用户浏览的wap格式。
显示条数：可自定义显示1-7条数据，例如用在Google日历中的短信提醒，就可以只输出一条，这样每天就能只收到第二天的天气预报。
雨雪预报：这应该是一个相当实用的更新，相信大部分用户并不太关心天晴情况，除非第二天可能有雨，当选中这个设置后，若第二天是非雨雪天气，则不会有数据输出，如果用在Google日历的提醒中，就不会每天都收到短信了。


在经历了数次更新后，这个系统也日趋完善，预计不久后就会将其加入实验室，开放源码供大家下载。
注：如何利用Google日历和本系统的数据源实现免费的天气预报提醒，请移步《天气预报V2隆重上线测试》一文中的网友介绍或自行搜索。
相关文章

老版天气预报系统停止提供服务 (1)
关注天气：免费的短信天气预报 (126)
天气预报V2隆重上线测试 (81)
制作自己的天气预报站点 (25)


本文出自周帆的Web实验室，转载时请注明作者及出处

查看原文 &#124;
对文章内容发表评论]]></description>
			<content:encoded><![CDATA[<p><a href="http://weather.raychou.com/">天气预报系统</a>一直都有很多网友在使用和关注，我也一直没有放弃更新。但一直因为原来的代码部署方式过于麻烦而一直没有做大的改进。在部署了<a href="http://www.raychou.com/chou/posts/319.htm">新的开发方式</a>后，一方面正好可以测试这套方案的健壮性，另一方面也把以前网友们提出的建议实现。</p>
<p>这次更新最大的改进是支持自定义数据格式，用户可以根据自己的需要选择数据格式，输出的条数，以及是否只显示雨雪天气预报。</p>
<ol>
<li><strong>数据格式</strong>：目前提供了html,rss,ical三种格式输出，计划中还要提供json，以及方便手机用户浏览的wap格式。</li>
<li><strong>显示条数</strong>：可自定义显示1-7条数据，例如用在Google日历中的短信提醒，就可以只输出一条，这样每天就能只收到第二天的天气预报。</li>
<li><strong>雨雪预报</strong>：这应该是一个相当实用的更新，相信大部分用户并不太关心天晴情况，除非第二天可能有雨，当选中这个设置后，若第二天是非雨雪天气，则不会有数据输出，如果用在Google日历的提醒中，就不会每天都收到短信了。</li>
</ol>
<p><img src="http://www.raychou.com/chou/wp-content/uploads/2009/05/2009-05-11-001716.jpg" alt="2009-05-11_001716.jpg" height="152" width="431"/></p>
<p>在经历了数次更新后，这个系统也日趋完善，预计不久后就会将其加入<a href="http://www.raychou.com/chou/labs">实验室</a>，开放源码供大家下载。</p>
<p><span style="COLOR: #ff0000">注：如何利用Google日历和本系统的数据源实现免费的天气预报提醒，请移步<a href="http://www.raychou.com/chou/posts/293.htm">《天气预报V2隆重上线测试》</a>一文中的网友介绍或自行搜索。</span></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/349.htm" title="老版天气预报系统停止提供服务">老版天气预报系统停止提供服务 (1)</a></li>
<li><a href="http://www.raychou.com/chou/posts/324.htm" title="关注天气：免费的短信天气预报">关注天气：免费的短信天气预报 (126)</a></li>
<li><a href="http://www.raychou.com/chou/posts/293.htm" title="天气预报V2隆重上线测试">天气预报V2隆重上线测试 (81)</a></li>
<li><a href="http://www.raychou.com/chou/posts/31.htm" title="制作自己的天气预报站点">制作自己的天气预报站点 (25)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/321.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/321.htm#comments">对文章内容发表评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/321.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让虚拟主机也用上SVN：适用于个人的开发部署方式</title>
		<link>http://www.raychou.com/chou/posts/319.htm</link>
		<comments>http://www.raychou.com/chou/posts/319.htm#comments</comments>
		<pubDate>Sat, 09 May 2009 10:11:00 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[部署]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[Hooks]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[开发]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/319.htm</guid>
		<description><![CDATA[注：本文仅针对没有条件在主机上安装SVN服务器的情况，例如使用虚拟主机的开发人员。如果满足以下几个情况，本文可能非常适合你：

开发人员只有一个人
服务器是虚拟主机只有ftp没有svn，并且也无法自己安装程序
厌烦了每次部署修改都要整理更新文件列表并逐个提交

前言：我为什么要做这样的一个东西？近一个月来，在Raychou.com上花了不少时间，新开了实验室和小技巧两个栏目，尤其是实验室，以后可能会经常要更新代码，而以往每次更新代码都是先在Eclipse里写好，然后打开FtpRush，切换到要更新的文件夹，将整个目录提交到服务器，繁琐又费时。更是因为这个原因，weather也有段时间没有更新了，我是懒人，但仅仅是懒于做繁琐而机械的工作，我需要改变这个现状，于是有了下面的内容。
相信很多开发人员和我一样，在工作之余还会管理个人网站，和网友们分享自己的经验和代码。应该大部分人都是租用的虚拟主机，这样平时在公司那一套使用SVN提交代码的方式就不管用了，每次更新程序，都要先整理一份修改记录，然后依次用FTP上传，麻烦耗时不说，还会经常遗漏文件，造成不必要的麻烦。
想要让线上代码和本地开发环境保持同步，方法也很多，最简单的可以利用CuteFtp，WinScp的文件夹监视功能，当被监视的文件夹内有修改动作，就会自动触发程序提交代码到服务器。但这样也有个弊端，在本地调试的修改也会带上线，虽然是方便了，但可能造成更大的问题。
之前我写过《利用SVN Hooks实现快速方便的代码管理/发布方式》一文，是利用SVN Hooks实现在提交代码到SVN时，自动部署更新的文件到测试服务器。同样的，利用Hooks，我们也可以把代码同步到FTP服务器，不同的是，这次的SVN服务器是架设在开发环境中，也就是说，不需要额外的服务器，任何人都可以通过SVN实现开发环境与线上的代码同步。

如图所示，当开发人员在本地开发并调试后，提交代码到本机SVN服务器，触发post-commit钩子，调用post-commit.bat，（由于对bat的语法不熟悉，在这个架构中，我用php代替bat，post-commit.bat仅做了在命令行下调用post-commit.php并传参），然后然后进行文件的同步处理。
大致流程如下：

开发人员提交代码到SVN服务器
提交完成后，自动调用post-commit钩子
钩子调用php脚本并传递三个参数：代码仓库路径，当前版本号，配置文件名
php脚本通过传递过来的参数取得并分析当前版本的更新日志
根据不同的情况（新增、修改、删除、重名民）来同步文件

post-commit.bat代码如下：

set PATH=D:\Program Files\WebServer\PHP5.2.6;%PATH%
php &#34;F:\wwwroot\site\raychou\labs\php-svn-hooks\post-commit.php&#34; &#34;%1&#34; %2 &#34;config/raychou.php&#34; 1&#38;gt;&#38;amp;2

除post-commit默认的%1和%2两个参数外，这里我还传了第三个参数&#8221;config/raychou.php&#8221;，这个参数是传递给PHP脚本，让其去读取指定的配置文件，这个配置文件是在同步过程中需要用到的一些设置，例如SVN工作目录，FTP帐号等设置。
php在接收到hooks传递过来的参数后，读取配置文件，连接本地SVN版本库，取得并分析本地更新日志，连接FTP服务器，开始同步文件。
关于SVN Hooks以及post-commit的参数传递，请参考这里http://www.subversion.org.cn/svnbook/1.4/svnbook.html#svn.ref.reposhooks
代码下载，代码部署结构请参考http://www.raychou.com/labs/
php-svn-hooks php-ftp-client php-svn-client
相关文章

利用SVN Hooks实现快速方便的代码管理/发布方式 (2)
PHP FTP Client：基于PHP的FTP客户端 (1)
UCHome二次开发规范 &#8211; 不同于Manyou的开发模式 (5)


本文出自周帆的Web实验室，转载时请注明作者及出处

查看原文 &#124;
已有5位网友发表了评论]]></description>
			<content:encoded><![CDATA[<p><span style="COLOR: #ff0000">注：本文仅针对没有条件在主机上安装SVN服务器的情况，例如使用虚拟主机的开发人员。如果满足以下几个情况，本文可能非常适合你：</span></p>
<ul>
<li>开发人员只有一个人</li>
<li>服务器是虚拟主机只有ftp没有svn，并且也无法自己安装程序</li>
<li>厌烦了每次部署修改都要整理更新文件列表并逐个提交</li>
</ul>
<p><strong>前言：我为什么要做这样的一个东西？</strong>近一个月来，在Raychou.com上花了不少时间，新开了<a href="http://www.raychou.com/chou/labs">实验室</a>和<a href="http://www.raychou.com/chou/skill">小技巧</a>两个栏目，尤其是实验室，以后可能会经常要更新代码，而以往每次更新代码都是先在Eclipse里写好，然后打开<a href="http://www.ftprush.com/" target="_blank">FtpRush</a>，切换到要更新的文件夹，将整个目录提交到服务器，繁琐又费时。更是因为这个原因，<a href="http://weather.raychou.com/">weather</a>也有段时间没有更新了，我是懒人，但仅仅是懒于做繁琐而机械的工作，我需要改变这个现状，于是有了下面的内容。</p>
<p>相信很多开发人员和我一样，在工作之余还会管理个人网站，和网友们分享自己的经验和代码。应该大部分人都是租用的虚拟主机，这样平时在公司那一套使用SVN提交代码的方式就不管用了，每次更新程序，都要先整理一份修改记录，然后依次用FTP上传，麻烦耗时不说，还会经常遗漏文件，造成不必要的麻烦。</p>
<p>想要让线上代码和本地开发环境保持同步，方法也很多，最简单的可以利用CuteFtp，WinScp的文件夹监视功能，当被监视的文件夹内有修改动作，就会自动触发程序提交代码到服务器。但这样也有个弊端，在本地调试的修改也会带上线，虽然是方便了，但可能造成更大的问题。</p>
<p>之前我写过<a href="http://www.raychou.com/chou/posts/247.htm" title="利用SVN Hooks实现快速方便的代码管理/发布方式">《利用SVN Hooks实现快速方便的代码管理/发布方式》</a>一文，是利用SVN Hooks实现在提交代码到SVN时，自动部署更新的文件到测试服务器。同样的，利用Hooks，我们也可以把代码同步到FTP服务器，不同的是，这次的SVN服务器是架设在开发环境中，也就是说，不需要额外的服务器，任何人都可以通过SVN实现开发环境与线上的代码同步。</p>
<p><img src="http://www.raychou.com/chou/wp-content/uploads/2009/05/php-svn-hooks.gif" alt="php-svn-hooks.gif" height="548" width="513"/></p>
<p>如图所示，当开发人员在本地开发并调试后，提交代码到本机SVN服务器，触发post-commit钩子，调用post-commit.bat，（由于对bat的语法不熟悉，在这个架构中，我用php代替bat，post-commit.bat仅做了在命令行下调用post-commit.php并传参），然后然后进行文件的同步处理。</p>
<p>大致流程如下：</p>
<ol>
<li>开发人员提交代码到SVN服务器</li>
<li>提交完成后，自动调用post-commit钩子</li>
<li>钩子调用php脚本并传递三个参数：代码仓库路径，当前版本号，配置文件名</li>
<li>php脚本通过传递过来的参数取得并分析当前版本的更新日志</li>
<li>根据不同的情况（新增、修改、删除、重名民）来同步文件</li>
</ol>
<p>post-commit.bat代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="bat" style="font-family:monospace;">set PATH=D:\Program Files\WebServer\PHP5.2.6;%PATH%
php &quot;F:\wwwroot\site\raychou\labs\php-svn-hooks\post-commit.php&quot; &quot;%1&quot; %2 &quot;config/raychou.php&quot; 1&amp;gt;&amp;amp;2</pre></div></div>

<p>除post-commit默认的%1和%2两个参数外，这里我还传了第三个参数&#8221;config/raychou.php&#8221;，这个参数是传递给PHP脚本，让其去读取指定的配置文件，这个配置文件是在同步过程中需要用到的一些设置，例如SVN工作目录，FTP帐号等设置。</p>
<p>php在接收到hooks传递过来的参数后，读取配置文件，连接本地SVN版本库，取得并分析本地更新日志，连接FTP服务器，开始同步文件。</p>
<p>关于SVN Hooks以及post-commit的参数传递，请参考这里<a href="http://www.subversion.org.cn/svnbook/1.4/svnbook.html#svn.ref.reposhooks" target="_blank">http://www.subversion.org.cn/svnbook/1.4/svnbook.html#svn.ref.reposhooks</a></p>
<p>代码下载，代码部署结构请参考<a href="http://www.raychou.com/labs/">http://www.raychou.com/labs/</a></p>
<p><a href="http://www.raychou.com/labs/php-svn-hooks/php-svn-hooks.zip" title="php-svn-hooks">php-svn-hooks</a> <a href="http://www.raychou.com/labs/php-ftp-client/php-ftp-client.zip" title="php-ftp-client">php-ftp-client</a> <a href="http://www.raychou.com/labs/php-svn-client/php-svn-client.zip" title="php-svn-client">php-svn-client</a></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/247.htm" title="利用SVN Hooks实现快速方便的代码管理/发布方式">利用SVN Hooks实现快速方便的代码管理/发布方式 (2)</a></li>
<li><a href="http://www.raychou.com/chou/posts/346.htm" title="PHP FTP Client：基于PHP的FTP客户端">PHP FTP Client：基于PHP的FTP客户端 (1)</a></li>
<li><a href="http://www.raychou.com/chou/posts/276.htm" title="UCHome二次开发规范 &#8211; 不同于Manyou的开发模式">UCHome二次开发规范 &#8211; 不同于Manyou的开发模式 (5)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/319.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/319.htm#comments">已有5位网友发表了评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/319.htm/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>LinkageSelect 基于jQuery的联动下拉菜单</title>
		<link>http://www.raychou.com/chou/posts/317.htm</link>
		<comments>http://www.raychou.com/chou/posts/317.htm#comments</comments>
		<pubDate>Sat, 25 Apr 2009 06:04:00 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[实验室]]></category>
		<category><![CDATA[程序开发]]></category>
		<category><![CDATA[联动菜单]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/317.htm</guid>
		<description><![CDATA[在Web开发中联动下拉菜单的应用非常广泛，拿我们最常见的地区选择来说，相信几乎所有的网友都填过下面这样的表单：

当选择省份后，之后的下拉菜单中会自动给出前一个菜单中所选省份内的城市，以此类推，当选择城市后，再后面一个菜单会自动给出区或县城让用户选择，简单说就是每一次的选择都会影响下一个菜单的可选项，我们称之为联动菜单。
这样的JS代码在网上很多，我曾经也写过一个全国省市区三级联动下拉菜单，在项目中也得到了应用，但在实际项目中，需要使用类似这样联动菜单的地方很多，比如类别的选择等等，这样我就需要为每一个需求去写一份代码，而其中90%以上的代码都是重复或相似的，不但浪费了时间，用户在浏览网页时更需要下载大量重复的代码，增加不必要的开销。
因此我也一直有想法，将联动功能与联动数据分离开来，让一份JS代码能够适应不同的联动菜单需求，于是便有了LinkageSelect，基于jQuery的联动选择菜单。目前已经实现但不局限于以下功能：

数据与代码分离，对应不同的菜单只需要准备不同的数据
支持变量数据或AJAX调用外部数据
支持自定义菜单根节点
支持自定义菜单默认选中值
可动态改变调用的菜单数据

在当前发布的版本中，还包括一个DataBuilder，支持手工创建用于LinkageSelect的JSON动态数据源。计划中就不再提供其他数据装换工具，有需要的朋友可以研究DataBuilder数据库格式，自行导入，再通过json.php输出所需数据源。
在线演示
相关文章

jQuery投票插件RaterStar顺利毕业 (25)
jQuery Rater Star Plugin 修正：自定义Title后无法点击星星 (3)
轻量级表单验证插件 jQuery.Validation (3)
RaterStar更新：支持自定义鼠标悬停Title (2)
LinkageSelect新增AJAX方式调用数据 (4)


本文出自周帆的Web实验室，转载时请注明作者及出处

查看原文 &#124;
已有7位网友发表了评论]]></description>
			<content:encoded><![CDATA[<p>在Web开发中联动下拉菜单的应用非常广泛，拿我们最常见的地区选择来说，相信几乎所有的网友都填过下面这样的表单：</p>
<p><img src="http://www.raychou.com/chou/wp-content/uploads/2009/04/2009-04-25-141108.jpg" alt="2009-04-25_141108.jpg" height="47" width="313"/></p>
<p>当选择省份后，之后的下拉菜单中会自动给出前一个菜单中所选省份内的城市，以此类推，当选择城市后，再后面一个菜单会自动给出区或县城让用户选择，简单说就是每一次的选择都会影响下一个菜单的可选项，我们称之为联动菜单。</p>
<p>这样的JS代码在网上很多，我曾经也写过一个<a href="http://www.raychou.com/demo/location/" target="_blank">全国省市区三级联动下拉菜单</a>，在项目中也得到了应用，但在实际项目中，需要使用类似这样联动菜单的地方很多，比如类别的选择等等，这样我就需要为每一个需求去写一份代码，而其中90%以上的代码都是重复或相似的，不但浪费了时间，用户在浏览网页时更需要下载大量重复的代码，增加不必要的开销。</p>
<p>因此我也一直有想法，将联动功能与联动数据分离开来，让一份JS代码能够适应不同的联动菜单需求，于是便有了<a href="http://www.raychou.com/labs/linkage-select/" target="_blank">LinkageSelect</a>，基于jQuery的联动选择菜单。目前已经实现但不局限于以下功能：</p>
<ul>
<li>数据与代码分离，对应不同的菜单只需要准备不同的数据</li>
<li>支持变量数据或AJAX调用外部数据</li>
<li>支持自定义菜单根节点</li>
<li>支持自定义菜单默认选中值</li>
<li>可动态改变调用的菜单数据</li>
</ul>
<p>在当前发布的版本中，还包括一个<a href="http://www.raychou.com/labs/linkage-select/data_builder/" target="_blank">DataBuilder</a>，支持手工创建用于LinkageSelect的JSON动态数据源。计划中就不再提供其他数据装换工具，有需要的朋友可以研究DataBuilder数据库格式，自行导入，再通过json.php输出所需数据源。</p>
<p><a href="http://www.raychou.com/labs/linkage-select/" target="_blank">在线演示</a></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/329.htm" title="jQuery投票插件RaterStar顺利毕业">jQuery投票插件RaterStar顺利毕业 (25)</a></li>
<li><a href="http://www.raychou.com/chou/posts/303.htm" title="jQuery Rater Star Plugin 修正：自定义Title后无法点击星星">jQuery Rater Star Plugin 修正：自定义Title后无法点击星星 (3)</a></li>
<li><a href="http://www.raychou.com/chou/posts/221.htm" title="轻量级表单验证插件 jQuery.Validation">轻量级表单验证插件 jQuery.Validation (3)</a></li>
<li><a href="http://www.raychou.com/chou/posts/352.htm" title="RaterStar更新：支持自定义鼠标悬停Title">RaterStar更新：支持自定义鼠标悬停Title (2)</a></li>
<li><a href="http://www.raychou.com/chou/posts/327.htm" title="LinkageSelect新增AJAX方式调用数据">LinkageSelect新增AJAX方式调用数据 (4)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/317.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/317.htm#comments">已有7位网友发表了评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/317.htm/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>jQuery Rater Star Plugin 修正：自定义Title后无法点击星星</title>
		<link>http://www.raychou.com/chou/posts/303.htm</link>
		<comments>http://www.raychou.com/chou/posts/303.htm#comments</comments>
		<pubDate>Sun, 22 Mar 2009 01:16:32 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[投票]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/303.htm</guid>
		<description><![CDATA[Demo/Download请猛击 -&#62; http://www.raychou.com/demo/jquery-rater/
相关文章

jQuery投票插件RaterStar顺利毕业 (25)
RaterStar更新：支持自定义鼠标悬停Title (2)
LinkageSelect 基于jQuery的联动下拉菜单 (7)
轻量级表单验证插件 jQuery.Validation (3)
UCHome二次开发规范 &#8211; 不同于Manyou的开发模式 (5)


本文出自周帆的Web实验室，转载时请注明作者及出处

查看原文 &#124;
已有3位网友发表了评论]]></description>
			<content:encoded><![CDATA[<p>Demo/Download请猛击 -&gt; <a href="http://www.raychou.com/demo/jquery-rater/" target="_blank">http://www.raychou.com/demo/jquery-rater/</a></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/329.htm" title="jQuery投票插件RaterStar顺利毕业">jQuery投票插件RaterStar顺利毕业 (25)</a></li>
<li><a href="http://www.raychou.com/chou/posts/352.htm" title="RaterStar更新：支持自定义鼠标悬停Title">RaterStar更新：支持自定义鼠标悬停Title (2)</a></li>
<li><a href="http://www.raychou.com/chou/posts/317.htm" title="LinkageSelect 基于jQuery的联动下拉菜单">LinkageSelect 基于jQuery的联动下拉菜单 (7)</a></li>
<li><a href="http://www.raychou.com/chou/posts/221.htm" title="轻量级表单验证插件 jQuery.Validation">轻量级表单验证插件 jQuery.Validation (3)</a></li>
<li><a href="http://www.raychou.com/chou/posts/276.htm" title="UCHome二次开发规范 &#8211; 不同于Manyou的开发模式">UCHome二次开发规范 &#8211; 不同于Manyou的开发模式 (5)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/303.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/303.htm#comments">已有3位网友发表了评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/303.htm/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP autoload与include性能比较</title>
		<link>http://www.raychou.com/chou/posts/299.htm</link>
		<comments>http://www.raychou.com/chou/posts/299.htm#comments</comments>
		<pubDate>Sat, 07 Mar 2009 13:34:00 +0000</pubDate>
		<dc:creator>RayChou</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[autoload]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[性能]]></category>
		<category><![CDATA[测试]]></category>

		<guid isPermaLink="false">http://www.raychou.com/chou/posts/299.htm</guid>
		<description><![CDATA[自PHP5后，官方大大丰富了对面向对象的支持，其中有个重要改变：引入了__autoload()函数，从此不再需要在php脚本的header写一堆的require或include了，用PHP函数手册中的话说：&#8221;它会在试图使用尚未被定义的类时自动调用&#8221;。
这一机制大大减轻了开发人员的负担，只要在架构初期考虑好了目录结构和命名规范，在开发过程中，需要再为代码中要用到的类分别去require相应的文件，减少了大量代码。
但这样一来，也容易出现运行一个程序，某个类文件被include多次，例如有以下四个脚本：

#file:include1.php 
include 'include2.php'; 
//@todo something


#file:include2.php 
//@todo something


#file:script1.php 
include 'include2.php'; 
//@todo something


#file:script2.php 
include 'include1.php'; 
include 'script1.php' 
//@todo something

当执行script1.php时， include &#8216;include2.php&#8217;; 这行代码被执行了一次。而执行script2.php时，这行代码被执行了两次。
这里只是一个简单的例子，在实际的项目中，include2.php被include的次数可能更多。这样反复的include，是否会影响性能呢？为此我写了个脚本来测试。

#file:SimpleClass.php
class SimpleClass &#123;
        public function __construct&#40;&#41; &#123;
                echo get_time&#40;&#41; . &#34;\r\n&#34;;
    [...]]]></description>
			<content:encoded><![CDATA[<p>自PHP5后，官方大大丰富了对面向对象的支持，其中有个重要改变：引入了<a href="http://cn.php.net/__autoload" target="_blank" title="autoload函数说明">__autoload()</a>函数，从此不再需要在php脚本的header写一堆的require或include了，用PHP函数手册中的话说：&#8221;它会在试图使用尚未被定义的类时自动调用&#8221;。</p>
<p>这一机制大大减轻了开发人员的负担，只要在架构初期考虑好了目录结构和命名规范，在开发过程中，需要再为代码中要用到的类分别去require相应的文件，减少了大量代码。</p>
<p>但这样一来，也容易出现运行一个程序，某个类文件被include多次，例如有以下四个脚本：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#file:include1.php 
</span><span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'include2.php'</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//@todo something</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#file:include2.php 
</span><span style="color: #666666; font-style: italic;">//@todo something</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#file:script1.php 
</span><span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'include2.php'</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//@todo something</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#file:script2.php 
</span><span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'include1.php'</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'script1.php'</span> 
<span style="color: #666666; font-style: italic;">//@todo something</span></pre></div></div>

<p>当执行script1.php时， <strong><span style="COLOR: #ff0000"><strong>include &#8216;include2.php&#8217;;</strong></span></strong> 这行代码被执行了一次。而执行script2.php时，这行代码被执行了两次。</p>
<p>这里只是一个简单的例子，在实际的项目中，include2.php被include的次数可能更多。这样反复的include，是否会影响性能呢？为此我写了个脚本来测试。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#file:SimpleClass.php
</span><span style="color: #000000; font-weight: bold;">class</span> SimpleClass <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">echo</span> get_time<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#file:php_include.php
</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: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #000088;">$loop</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;">include_once</span> <span style="color: #0000ff;">&quot;SimpleClass.php&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">new</span> SimpleClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>当$loop值为1时，脚本耗时约0.00018906593322754秒，当$loop为1000时，脚本耗时约0.076701879501343秒。</p>
<p>如果我们用autoload实现呢？</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#file:php_autoload.php
</span><span style="color: #000000; font-weight: bold;">function</span> __autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$class_name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">include_once</span> <span style="color: #000088;">$class_name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</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> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #000088;">$loop</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: #000000; font-weight: bold;">new</span> SimpleClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>在这段代码中，我定义了__autoload函数，几乎一样的脚本，当$loop为1时，耗时0.0002131462097168秒，而当$loop为1000时，耗时仅为前面代码的1/7，0.012391805648804秒。</p>
<p>但请注意看SimpleClass的代码，其中输出了一行字符串，如果去掉这行输出后再比较，会是什么样的结果呢？</p>
<p>在$loop同为1000的情况下，前者耗时0.057836055755615秒，而使用了autoload后，仅仅0.00199294090271秒！效率相差近30倍！</p>
<p>从上面的测试可以看出，当文件仅仅被include一次，autoload会消耗稍微多一点的时间，但如果在文件被反复include的情况下，使用autoload则能大大提高系统性能。</p>
<p>至于是否要使用autoload来解放程序员，这就仁者见仁，智者见智了。在我看来，条件允许的前提下，牺牲这一点性能（某些情况下，可能是提升性能），换来更为便捷的开发，是值得的。</p>
<p>附：<a href="http://www.raychou.com/test/php_autoload/php_autoload.zip">本文测试脚本下载</a></p>
<h3>相关文章</h3>
<ul class="related_post">
<li><a href="http://www.raychou.com/chou/posts/356.htm" title="在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer">在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer (2)</a></li>
<li><a href="http://www.raychou.com/chou/posts/346.htm" title="PHP FTP Client：基于PHP的FTP客户端">PHP FTP Client：基于PHP的FTP客户端 (1)</a></li>
<li><a href="http://www.raychou.com/chou/posts/334.htm" title="PHP连贯接口">PHP连贯接口 (0)</a></li>
<li><a href="http://www.raychou.com/chou/posts/207.htm" title="转战Eclipse">转战Eclipse (0)</a></li>
<li><a href="http://www.raychou.com/chou/posts/193.htm" title="[转]Java在Web开发语言上败给了PHP">[转]Java在Web开发语言上败给了PHP (1)</a></li>
</ul>
<hr />
本文出自<a href="http://www.raychou.com/chou">周帆的Web实验室</a>，转载时请注明作者及出处
<br />
<a href="http://www.raychou.com/chou/posts/299.htm">查看原文</a> |
<a href="http://www.raychou.com/chou/posts/299.htm#comments">已有3位网友发表了评论</a>]]></content:encoded>
			<wfw:commentRss>http://www.raychou.com/chou/posts/299.htm/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
