<?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>No Site Name</title>
	<atom:link href="http://hliang.sinaapp.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://hliang.sinaapp.com</link>
	<description>人生无彩排，每一天都是LIVING SHOW. 黄亮的BLOG.</description>
	<lastBuildDate>Sat, 19 May 2012 16:54:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Redis中删除SortSet的最大Score和最小Score</title>
		<link>http://hliang.sinaapp.com/?p=1005</link>
		<comments>http://hliang.sinaapp.com/?p=1005#comments</comments>
		<pubDate>Wed, 16 May 2012 02:38:34 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[缓存]]></category>

		<guid isPermaLink="false">http://blog.ixcv.com/?p=1005</guid>
		<description><![CDATA[删除最小Score 1 zremrangebyrank key 0 0 删除最大Score 1 zremrangebyrank key -1 -1]]></description>
			<content:encoded><![CDATA[<p>删除最小Score</p>

<div class="wp_codebox"><table><tr id="p10053"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1005code3"><pre class="python" style="font-family:monospace;">zremrangebyrank key <span style="color: #ff4500;">0</span> <span style="color: #ff4500;">0</span></pre></td></tr></table></div>

<p>删除最大Score</p>

<div class="wp_codebox"><table><tr id="p10054"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1005code4"><pre class="python" style="font-family:monospace;">zremrangebyrank key -<span style="color: #ff4500;">1</span> -<span style="color: #ff4500;">1</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=1005</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python中，时间字符串与时间戳的互相转换</title>
		<link>http://hliang.sinaapp.com/?p=994</link>
		<comments>http://hliang.sinaapp.com/?p=994#comments</comments>
		<pubDate>Tue, 15 May 2012 09:16:00 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://hliang.sinaapp.com/?p=994</guid>
		<description><![CDATA[时间字符串转换为时间戳： 1 2 3 4 import time timestring = '2012-05-15 17:12:37' timestamp = int&#40;time.mktime&#40;time.strptime&#40;timestring, '%Y-%m-%d %H:%M:%S'&#41;&#41;&#41; print timestamp 时间戳转换为时间字符串： 1 2 3 4 import time struct_time = time.localtime&#40;1337073342&#41; timestring = time.strftime&#40;'%Y-%m-%d %H:%M:%S',struct_time&#41; print timestring]]></description>
			<content:encoded><![CDATA[<p>时间字符串转换为时间戳：</p>

<div class="wp_codebox"><table><tr id="p9947"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p994code7"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span>
timestring = <span style="color: #483d8b;">'2012-05-15 17:12:37'</span>
timestamp = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: black;">mktime</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: black;">strptime</span><span style="color: black;">&#40;</span>timestring, <span style="color: #483d8b;">'%Y-%m-%d %H:%M:%S'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> timestamp</pre></td></tr></table></div>

<p>时间戳转换为时间字符串：</p>

<div class="wp_codebox"><table><tr id="p9948"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p994code8"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span>
struct_time = <span style="color: #dc143c;">time</span>.<span style="color: black;">localtime</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1337073342</span><span style="color: black;">&#41;</span>
timestring = <span style="color: #dc143c;">time</span>.<span style="color: black;">strftime</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'%Y-%m-%d %H:%M:%S'</span>,struct_time<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> timestring</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=994</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>在AJAX页面显示Loading&#8230;</title>
		<link>http://hliang.sinaapp.com/?p=991</link>
		<comments>http://hliang.sinaapp.com/?p=991#comments</comments>
		<pubDate>Mon, 14 May 2012 08:32:08 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://hliang.sinaapp.com/?p=991</guid>
		<description><![CDATA[直接贴代码： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 &#60;style&#62; #ajaxloading &#123;right:0; top:0; width:130px; position:fixed; padding:10px; text-align:center; font-weight:bold; background:#900; color:#FFF;&#125; * html #ajaxloading &#123;position:absolute; right:16px;&#125;/*only for ie*/ html &#123;overflow:auto !important; overflow:hidden;&#125; &#60;/style&#62; &#160; &#60;div id=&#34;ajaxloading&#34; style=&#34;display:none;&#34;&#62;正在加载，请稍候 ...&#60;/div&#62; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>直接贴代码：</p>

<div class="wp_codebox"><table><tr id="p99110"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code" id="p991code10"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>style<span style="color: #339933;">&gt;</span>
#ajaxloading <span style="color: #009900;">&#123;</span>right<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> top<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> width<span style="color: #339933;">:</span>130px<span style="color: #339933;">;</span> position<span style="color: #339933;">:</span>fixed<span style="color: #339933;">;</span> padding<span style="color: #339933;">:</span>10px<span style="color: #339933;">;</span> text<span style="color: #339933;">-</span>align<span style="color: #339933;">:</span>center<span style="color: #339933;">;</span> font<span style="color: #339933;">-</span>weight<span style="color: #339933;">:</span>bold<span style="color: #339933;">;</span> background<span style="color: #339933;">:</span>#<span style="color: #CC0000;">900</span><span style="color: #339933;">;</span> color<span style="color: #339933;">:</span>#FFF<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> 
<span style="color: #339933;">*</span> html #ajaxloading <span style="color: #009900;">&#123;</span>position<span style="color: #339933;">:</span>absolute<span style="color: #339933;">;</span> right<span style="color: #339933;">:</span>16px<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #006600; font-style: italic;">/*only for ie*/</span> 
html <span style="color: #009900;">&#123;</span>overflow<span style="color: #339933;">:</span>auto <span style="color: #339933;">!</span>important<span style="color: #339933;">;</span> overflow<span style="color: #339933;">:</span>hidden<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>style<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;ajaxloading&quot;</span> style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;display:none;&quot;</span><span style="color: #339933;">&gt;</span>正在加载，请稍候 ...<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> setPage<span style="color: #009900;">&#40;</span>ajax_url<span style="color: #339933;">,</span> sethistory<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#ajaxloading'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ajaxStart</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#ajaxloading'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ajaxStop</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span>ajax_url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#setpage'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>sethistory<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            history.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>ajax_url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=991</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13 个mod_rewrite 应用举例</title>
		<link>http://hliang.sinaapp.com/?p=986</link>
		<comments>http://hliang.sinaapp.com/?p=986#comments</comments>
		<pubDate>Thu, 10 May 2012 06:36:16 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[Apache/Nginx]]></category>

		<guid isPermaLink="false">http://hliang.sinaapp.com/?p=986</guid>
		<description><![CDATA[1．给子域名加www标记 1 2 3 RewriteCond %&#123;HTTP_HOST&#125; ^&#40;&#91;a-z.&#93;+&#41;?example\.com$ &#91;NC&#93; RewriteCond %&#123;HTTP_HOST&#125; !^www\. &#91;NC&#93; RewriteRule .? http://www.%1example.com%&#123;REQUEST_URI&#125; &#91;R=301,L&#93; 这个规则抓取二级域名的%1变量，如果不是以www开始，那么就加www，以前的域名以及{REQUEST_URI}会跟在其后。 2．去掉域名中的www标记 1 2 RewriteCond %&#123;HTTP_HOST&#125; !^example\.com$ &#91;NC&#93; RewriteRule .? &#60;a href=&#34;http://example.com/&#34; rel=&#34;nofollow&#34; target=&#34;_blank&#34;&#62;http://example.com&#60;/a&#62;%&#123;REQUEST_URI&#125; &#91;R=301,L&#93; 3．去掉www标记，但是保存子域名 1 2 RewriteCond %&#123;HTTP_HOST&#125; ^www\.&#40;&#40;&#91;a-z0-9_&#93;+\.&#41;?example\.com&#41;$ &#91;NC&#93; RewriteRule .? http://%1%&#123;REQUEST_URI&#125; &#91;R=301,L&#93; 这里，当匹配到1%变量以后，子域名才会在%2（内部原子）中抓取到，而我们需要的正是这个%1变量。 4．防止图片盗链 一些站长不择手段的将你的图片盗链在他们网站上，耗费你的带宽。你可以加一下 代码 阻止这种行为。 1 2 3 RewriteCond %&#123;HTTP_REFERER&#125; !^$ RewriteCond %&#123;HTTP_REFERER&#125; !^http://&#40;www\.&#41;?example\.com/ [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1．给子域名加www标记</strong></p>

<div class="wp_codebox"><table><tr id="p98629"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p986code29"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_HOST<span style="color: black;">&#125;</span> ^<span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>a-z.<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span>example\.<span style="color: black;">com</span>$ <span style="color: black;">&#91;</span>NC<span style="color: black;">&#93;</span>
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_HOST<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^www\. <span style="color: black;">&#91;</span>NC<span style="color: black;">&#93;</span>
RewriteRule .<span style="color: #66cc66;">?</span> http://www.<span style="color: #66cc66;">%</span>1example.<span style="color: black;">com</span><span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_URI<span style="color: black;">&#125;</span> <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>这个规则抓取二级域名的%1变量，如果不是以www开始，那么就加www，以前的域名以及{REQUEST_URI}会跟在其后。<span id="more-986"></span></p>
<p><strong>2．去掉域名中的www标记</strong></p>

<div class="wp_codebox"><table><tr id="p98630"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p986code30"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_HOST<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^example\.<span style="color: black;">com</span>$ <span style="color: black;">&#91;</span>NC<span style="color: black;">&#93;</span>
RewriteRule .<span style="color: #66cc66;">?</span> <span style="color: #66cc66;">&lt;</span>a href=<span style="color: #483d8b;">&quot;http://example.com/&quot;</span> rel=<span style="color: #483d8b;">&quot;nofollow&quot;</span> target=<span style="color: #483d8b;">&quot;_blank&quot;</span><span style="color: #66cc66;">&gt;</span>http://example.<span style="color: black;">com</span><span style="color: #66cc66;">&lt;</span>/a<span style="color: #66cc66;">&gt;%</span><span style="color: black;">&#123;</span>REQUEST_URI<span style="color: black;">&#125;</span> <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p><strong>3．去掉www标记，但是保存子域名</strong></p>

<div class="wp_codebox"><table><tr id="p98631"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p986code31"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_HOST<span style="color: black;">&#125;</span> ^www\.<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>a-z0-<span style="color: #ff4500;">9</span>_<span style="color: black;">&#93;</span>+\.<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span>example\.<span style="color: black;">com</span><span style="color: black;">&#41;</span>$ <span style="color: black;">&#91;</span>NC<span style="color: black;">&#93;</span>
RewriteRule .<span style="color: #66cc66;">?</span> http://<span style="color: #66cc66;">%</span>1<span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_URI<span style="color: black;">&#125;</span> <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>这里，当匹配到1%变量以后，子域名才会在%2（内部原子）中抓取到，而我们需要的正是这个%1变量。</p>
<p><strong>4．防止图片盗链</strong> </p>
<p>一些站长不择手段的将你的图片盗链在他们网站上，耗费你的带宽。你可以加一下 代码 阻止这种行为。</p>

<div class="wp_codebox"><table><tr id="p98632"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p986code32"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_REFERER<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^$
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_REFERER<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^http://<span style="color: black;">&#40;</span>www\.<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span>example\.<span style="color: black;">com</span>/ <span style="color: black;">&#91;</span>NC<span style="color: black;">&#93;</span>
RewriteRule \.<span style="color: black;">&#40;</span>gif|jpg|png<span style="color: black;">&#41;</span>$ - <span style="color: black;">&#91;</span>F<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>如果{HTTP_REFERER}值不为空，或者不是来自你自己的域名，这个规则用[F]FLAG阻止以gif|jpg|png 结尾的URL<br />
如果对这种盗链你是坚决鄙视的，你还可以改变图片，让访问盗链网站的用户知道该网站正在盗用你的图片。</p>

<div class="wp_codebox"><table><tr id="p98633"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p986code33"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_REFERER<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^$
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_REFERER<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^http://<span style="color: black;">&#40;</span>www\.<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span>example\.<span style="color: black;">com</span>/.<span style="color: #66cc66;">*</span>$ <span style="color: black;">&#91;</span>NC<span style="color: black;">&#93;</span>
RewriteRule \.<span style="color: black;">&#40;</span>gif|jpg|png<span style="color: black;">&#41;</span>$ 你的图片地址 <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>除了阻止图片盗链 链接 ，以上规则将其盗链的图片全部替换成了你 设置 的图片。<br />
你还可以阻止特定域名盗链你的图片：</p>

<div class="wp_codebox"><table><tr id="p98634"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p986code34"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTP_REFERER<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^http://<span style="color: black;">&#40;</span>www\.<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span>leech_site\.<span style="color: black;">com</span>/ <span style="color: black;">&#91;</span>NC<span style="color: black;">&#93;</span>
RewriteRule \.<span style="color: black;">&#40;</span>gif|jpg|png<span style="color: black;">&#41;</span>$ - <span style="color: black;">&#91;</span>F,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>这个规则将阻止域名黑名单上所有的图片链接请求。<br />
当然以上这些规则都是以{HTTP_REFERER}获取域名为基础的，如果你想改用成IP地址，用{REMOTE_ADDR}就可以了。</p>
<p><strong>5．如果文件不存在重定向到404页面</strong> </p>
<p>如果你的主机没有提供404页面重定向服务，那么我们自己创建。</p>

<div class="wp_codebox"><table><tr id="p98635"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p986code35"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_FILENAME<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>-f
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_FILENAME<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>-d
RewriteRule .<span style="color: #66cc66;">?</span> /<span style="color: #ff4500;">404</span>.<span style="color: black;">php</span> <span style="color: black;">&#91;</span>L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>这里-f匹配的是存在的文件名，-d匹配的存在的路径名。这段代码在进行404重定向之前，会判断你的文件名以及路径名是否存在。你还可以在404页面上加一个?url=$1参数：</p>

<div class="wp_codebox"><table><tr id="p98636"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p986code36"><pre class="python" style="font-family:monospace;">RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*</span><span style="color: black;">&#41;</span>$ /<span style="color: #ff4500;">404</span>.<span style="color: black;">php</span><span style="color: #66cc66;">?</span>url=$<span style="color: #ff4500;">1</span> <span style="color: black;">&#91;</span>L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>这样，你的404页面就可以做一些其他的事情，例如默认信心，发一个邮件提醒，加一个 搜索 ，等等。</p>
<p><strong>6．重命名目录</strong></p>
<p>如果你想在网站上重命名目录，试试这个：</p>

<div class="wp_codebox"><table><tr id="p98637"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p986code37"><pre class="python" style="font-family:monospace;">RewriteRule ^/<span style="color: #66cc66;">?</span>old_directory/<span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>a-z/.<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>$ new_directory/$<span style="color: #ff4500;">1</span> <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>在规则里我添加了一个“.”（注意不是代表得所有字符，前面有转义符）来匹配文件的后缀名。</p>
<p><strong>7．将.html后缀名转换成.php</strong></p>
<p>前提是.html文件能继续访问的情况下，更新你的网站链接。</p>

<div class="wp_codebox"><table><tr id="p98638"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p986code38"><pre class="python" style="font-family:monospace;">RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>a-z/<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>\.<span style="color: black;">html</span>$ $<span style="color: #ff4500;">1</span>.<span style="color: black;">php</span> <span style="color: black;">&#91;</span>L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>这不是一个网页重定向，所以访问者是不可见的。让他作为一个永久重定向（可见的），将FLAG修改[R=301,L]。</p>
<p><strong>8．创建无文件后缀名链接</strong></p>
<p>如果你想使你的 PHP 网站的链接更加简洁易记－或者隐藏文件的后缀名，试试这个:</p>

<div class="wp_codebox"><table><tr id="p98639"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p986code39"><pre class="python" style="font-family:monospace;">RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>a-z<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>$ $<span style="color: #ff4500;">1</span>.<span style="color: black;">php</span> <span style="color: black;">&#91;</span>L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>如果网站混有PHP以及HTML文件，你可以用RewriteCond先判断该后缀的文件是否存在，然后进行替换：</p>

<div class="wp_codebox"><table><tr id="p98640"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p986code40"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_FILENAME<span style="color: black;">&#125;</span>.<span style="color: black;">php</span> -f
RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>a-zA-Z0-<span style="color: #ff4500;">9</span><span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>$ $<span style="color: #ff4500;">1</span>.<span style="color: black;">php</span> <span style="color: black;">&#91;</span>L<span style="color: black;">&#93;</span>
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_FILENAME<span style="color: black;">&#125;</span>.<span style="color: black;">html</span> -f
RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>a-zA-Z0-<span style="color: #ff4500;">9</span><span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>$ $<span style="color: #ff4500;">1</span>.<span style="color: black;">html</span> <span style="color: black;">&#91;</span>L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>如果文件是以.php为后缀，这条规则将被执行。</p>
<p><strong>9．检查查询变量里的特定参数</strong></p>
<p>如果在URL里面有一个特殊的参数，你可用RewriteCond鉴别其是否存在：</p>

<div class="wp_codebox"><table><tr id="p98641"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p986code41"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>QUERY_STRING<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>uniquekey=
RewriteRule ^/<span style="color: #66cc66;">?</span>script_that_requires_uniquekey\.<span style="color: black;">php</span>$ other_script.<span style="color: black;">php</span> <span style="color: black;">&#91;</span>QSA,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>以上规则将检查{QUERY_STRING}里面的uniquekey参数是否存在，如果{REQUEST_URI}值为script_that_requires_uniquekey，将会定向到新的URL。</p>
<p><strong>10．删除查询变量</strong></p>
<p>Apache的mod_rewrite模块会自动辨识查询变量，除非你做了以下改动：</p>
<p>a).分配一个新的查询参数（你可以用[QSA,L]FLAG保存最初的查询变量）</p>
<p>b).在文件名后面加一个“?”（比如index.php?）。符号“?”不会在浏览器的地址栏里显示。</p>
<p><strong>11．用新的格式展示当前URI </strong></p>
<p>如果这就是我们当前正在运行的URLs：/index.php?id=nnnn。我们非常希望将其更改成/nnnn并且让搜索引擎以新格式展现。首先，我们 为了让搜索引擎更新成新的，得将旧的URLs重定向到新的格式，但是，我们还得保证以前的index.php照样能够运行。是不是被我搞迷糊了？</p>
<p>实现以上功能 ，诀窍就在于在查询变量中加了一个访问者看不到的标记符“marker”。我们只将查询变量中没有出现“marker”标记的链接进行重定向，然后将原有的链接替换成新的格式，并且通过[QSA]FLAG在已有的参数加一个“marker”标记。以下为实现的方式：</p>

<div class="wp_codebox"><table><tr id="p98642"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p986code42"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>QUERY_STRING<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>marker
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>QUERY_STRING<span style="color: black;">&#125;</span> <span style="color: #008000;">id</span>=<span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>-a-zA-Z0-<span style="color: #ff4500;">9</span>_+<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>
RewriteRule ^/<span style="color: #66cc66;">?</span>index\.<span style="color: black;">php</span>$ <span style="color: #66cc66;">%</span>1<span style="color: #66cc66;">?</span> <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span>
RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>-a-zA-Z0-<span style="color: #ff4500;">9</span>_+<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>$ index.<span style="color: black;">php</span><span style="color: #66cc66;">?</span>marker <span style="color: #66cc66;">&amp;</span>amp<span style="color: #66cc66;">;</span>id=$<span style="color: #ff4500;">1</span> <span style="color: black;">&#91;</span>L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>这里，原先的URL： http://www.example.com/index.php?id=nnnn ,不包含marker，所以被第一个规则永久重定向到 http://www.example.com/nnnn ，第二个规则将 http://www.example.com/nnnn 反定向到 http://www.example.com/index.php?marker&amp;id=nnnn，并且加了marker以及id=nnnn两个变量，最后mod_rewrite就开始进行处理过程。</p>
<p>第二次匹配，marker被匹配，所以忽略第一条规则，这里有一个“.”字符会出现在 http://www.example.com/index.php?marker&amp;id=nnnn中，所以第二条规则也会被忽略，这样我们就完成了。</p>
<p>注意，这个 解决 方案要求Apache的一些扩展功能，所以如果你的网站放于在共享主机中会遇到很多障碍。</p>
<p><strong>12．保证安全服务启用</strong></p>

<div class="wp_codebox"><table><tr id="p98643"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p986code43"><pre class="python" style="font-family:monospace;">Apache可以用两种方法辨别你是否开启了安全服务，分别引用<span style="color: black;">&#123;</span>HTTPS<span style="color: black;">&#125;</span>和<span style="color: black;">&#123;</span>SERVER_PORT<span style="color: black;">&#125;</span>变量：
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_URI<span style="color: black;">&#125;</span> ^secure_page\.<span style="color: black;">php</span>$
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>HTTPS<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>on
RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span>secure_page\.<span style="color: black;">php</span><span style="color: black;">&#41;</span>$ https://www.<span style="color: black;">example</span>.<span style="color: black;">com</span>/$<span style="color: #ff4500;">1</span> <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>以上规则测试{REQUEST_URI}值是否等于我们的安全页代码，并且{HTTPS}不等于on。如果这两个条件同时满足，请求将被重定向到安全服务URI.另外你可用{SERVER_PORT}做同样的测试，443是常用的安全服务端口。</p>

<div class="wp_codebox"><table><tr id="p98644"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p986code44"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_URI<span style="color: black;">&#125;</span> ^secure_page\.<span style="color: black;">php</span>$
RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>SERVER_PORT<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^<span style="color: #ff4500;">443</span>$
RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span>secure_page\.<span style="color: black;">php</span><span style="color: black;">&#41;</span>$ https://www.<span style="color: black;">example</span>.<span style="color: black;">com</span>/$<span style="color: #ff4500;">1</span> <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p><strong>13．在特定的页面上强制执行安全服务</strong> </p>
<p>遇到同一个服务器根目录下分别有一个安全服务域名和一个非安全服务域名，所以你就需要用RewriteCond 判断安全服务端口是否占用，并且只将以下列表的页面要求为安全服务：</p>

<div class="wp_codebox"><table><tr id="p98645"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p986code45"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>SERVER_PORT<span style="color: black;">&#125;</span> <span style="color: #66cc66;">!</span>^<span style="color: #ff4500;">443</span>$
RewriteRule ^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span>page1|page2|page3|page4|page5<span style="color: black;">&#41;</span>$ https://www.<span style="color: black;">example</span>.<span style="color: black;">com</span>/<span style="color: #66cc66;">%</span>1 <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>以下是怎样将没有设置成安全服务的页面返回到80端口：</p>

<div class="wp_codebox"><table><tr id="p98646"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p986code46"><pre class="python" style="font-family:monospace;">RewriteCond <span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span> SERVER_PORT <span style="color: black;">&#125;</span> ^<span style="color: #ff4500;">443</span>$
RewriteRule <span style="color: #66cc66;">!</span>^/<span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span>page6|page7|page8|page9<span style="color: black;">&#41;</span>$http://www.<span style="color: black;">example</span>.<span style="color: black;">com</span><span style="color: #66cc66;">%</span><span style="color: black;">&#123;</span>REQUEST_URI<span style="color: black;">&#125;</span> <span style="color: black;">&#91;</span>R=<span style="color: #ff4500;">301</span>,L<span style="color: black;">&#93;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=986</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>小结一下</title>
		<link>http://hliang.sinaapp.com/?p=969</link>
		<comments>http://hliang.sinaapp.com/?p=969#comments</comments>
		<pubDate>Wed, 25 Apr 2012 14:23:33 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[我的生活]]></category>

		<guid isPermaLink="false">http://hliang.sinaapp.com/?p=969</guid>
		<description><![CDATA[一转眼已经一年多了，去年的2月20日到新公司入职，3月8日开始，到北京开始出差。总结果一下过去的一年，有得有失吧。。。 先说说得吧。 到了新的公司、新的岗位，经历了新的事，接触到了新的人。感觉一切的一切都是新鲜的。自己突然又觉得有好多好多不懂或是不明白的事情，需要在短时间内搞定。感觉像是回到了当初刚刚开始工作的那段时间，不断的在吸收着新的知识。 在项目中，也接触到了新的技术，试过了新的工作流程。有好也有坏，有习惯，但更多的是不习惯。 在过去了的一个年头里，实现了自己“开发一套框架”的愿望。以项目为蓝本，开发了一套PHP开发框架，并成功的将其应用到了其他的子项目中，证明了框架的可用性。 而且现在还在为转为管理岗位而努力着。。。 再说说“失”了哪些。。。 过去的整个2011年以及2012年到现在过完了的小半年，最对不起的恐怕就是媳妇了。 媳妇在家怀孕10个月，我出差在外待了10个月。宝宝出生，也只在家待了半个月而已。。。心里满是愧疚啊。。。 没有办法参与到宝宝的成长过程中，失掉的乐趣，恐怕也只有自己能够体会得到。。。满心苦楚。。。 马上就要五一回家了，盼着回家与妻女团聚。。。虽说只是短暂的团聚，聊胜于无吧。。。]]></description>
			<content:encoded><![CDATA[<p>一转眼已经一年多了，去年的2月20日到新公司入职，3月8日开始，到北京开始出差。总结果一下过去的一年，有得有失吧。。。</p>
<p>先说说得吧。</p>
<p>到了新的公司、新的岗位，经历了新的事，接触到了新的人。感觉一切的一切都是新鲜的。自己突然又觉得有好多好多不懂或是不明白的事情，需要在短时间内搞定。感觉像是回到了当初刚刚开始工作的那段时间，不断的在吸收着新的知识。</p>
<p>在项目中，也接触到了新的技术，试过了新的工作流程。有好也有坏，有习惯，但更多的是不习惯。</p>
<p>在过去了的一个年头里，实现了自己“开发一套框架”的愿望。以项目为蓝本，开发了一套PHP开发框架，并成功的将其应用到了其他的子项目中，证明了框架的可用性。</p>
<p>而且现在还在为转为管理岗位而努力着。。。</p>
<p>再说说“失”了哪些。。。</p>
<p>过去的整个2011年以及2012年到现在过完了的小半年，最对不起的恐怕就是媳妇了。</p>
<p>媳妇在家怀孕10个月，我出差在外待了10个月。宝宝出生，也只在家待了半个月而已。。。心里满是愧疚啊。。。</p>
<p>没有办法参与到宝宝的成长过程中，失掉的乐趣，恐怕也只有自己能够体会得到。。。满心苦楚。。。</p>
<p>马上就要五一回家了，盼着回家与妻女团聚。。。虽说只是短暂的团聚，聊胜于无吧。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=969</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CKEditor插件开发</title>
		<link>http://hliang.sinaapp.com/?p=905</link>
		<comments>http://hliang.sinaapp.com/?p=905#comments</comments>
		<pubDate>Wed, 25 Apr 2012 11:31:52 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://hliang.sinaapp.com/?p=905</guid>
		<description><![CDATA[最近手头项目用到了富文本编辑器，而且要自己开发一些编辑器的插件，于是便直接使用了CKEditor。 CKEditor是目前能见到的比较灵活的WYSIWYG编辑器之一，在CKEditor上做扩展非常容易，而且界面的一致性也能得到很好的保证。 这里简单的把插件开发过程记录下来，留个存档，供以后需要之时翻来查用。 在插件目录plugin下建立自己的插件目录“myplugin”。 建立plugin.js，文件内容如下： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 CKEDITOR.plugins.add&#40;'myplugin', &#123; requires: &#91;'dialog'&#93;, init: function&#40;editor&#41; &#123; // 插件标识 var pluginName = 'myplugin'; // 启用对话框 var dialog = editor.addCommand&#40;pluginName, new CKEDITOR.dialogCommand&#40;pluginName&#41;&#41;; CKEDITOR.dialog.add&#40;pluginName, CKEDITOR.plugins.getPath&#40;pluginName&#41; + myplugin + '.js'&#41;; editor.ui.addButton&#40;'uploadpic', &#123; // 插件名称 label: '我的插件', [...]]]></description>
			<content:encoded><![CDATA[<p>最近手头项目用到了富文本编辑器，而且要自己开发一些编辑器的插件，于是便直接使用了CKEditor。</p>
<p>CKEditor是目前能见到的比较灵活的WYSIWYG编辑器之一，在CKEditor上做扩展非常容易，而且界面的一致性也能得到很好的保证。</p>
<p>这里简单的把插件开发过程记录下来，留个存档，供以后需要之时翻来查用。<span id="more-905"></span></p>
<p>在插件目录plugin下建立自己的插件目录“myplugin”。</p>
<p>建立plugin.js，文件内容如下：</p>

<div class="wp_codebox"><table><tr id="p90550"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p905code50"><pre class="javascript" style="font-family:monospace;">CKEDITOR.<span style="color: #660066;">plugins</span>.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myplugin'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
	 requires<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'dialog'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
	 init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>editor<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// 插件标识</span>
		<span style="color: #003366; font-weight: bold;">var</span> pluginName <span style="color: #339933;">=</span> <span style="color: #3366CC;">'myplugin'</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">// 启用对话框</span>
		<span style="color: #003366; font-weight: bold;">var</span> dialog <span style="color: #339933;">=</span> editor.<span style="color: #660066;">addCommand</span><span style="color: #009900;">&#40;</span>pluginName<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">new</span> CKEDITOR.<span style="color: #660066;">dialogCommand</span><span style="color: #009900;">&#40;</span>pluginName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		CKEDITOR.<span style="color: #660066;">dialog</span>.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>pluginName<span style="color: #339933;">,</span> CKEDITOR.<span style="color: #660066;">plugins</span>.<span style="color: #660066;">getPath</span><span style="color: #009900;">&#40;</span>pluginName<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> myplugin <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		editor.<span style="color: #660066;">ui</span>.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'uploadpic'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// 插件名称</span>
			label<span style="color: #339933;">:</span> <span style="color: #3366CC;">'我的插件'</span><span style="color: #339933;">,</span>
			command<span style="color: #339933;">:</span> pluginName<span style="color: #339933;">,</span>
			<span style="color: #006600; font-style: italic;">// 设置工具栏按钮图片</span>
			icon<span style="color: #339933;">:</span> CKEDITOR.<span style="color: #660066;">plugins</span>.<span style="color: #660066;">getPath</span><span style="color: #009900;">&#40;</span>pluginName<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> myplugin <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.png'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>建立myplugin.js，文件内容如下：</p>

<div class="wp_codebox"><table><tr id="p90551"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code" id="p905code51"><pre class="javascript" style="font-family:monospace;">CKEDITOR.<span style="color: #660066;">dialog</span>.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myplugin'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>editor<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> escape <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> value<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// 弹窗标题</span>
		title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'我的插件'</span><span style="color: #339933;">,</span>
		<span style="color: #006600; font-style: italic;">// 是否可以调整大小</span>
		resizable<span style="color: #339933;">:</span> CKEDITOR.<span style="color: #660066;">DIALOG_RESIZE_BOTH</span><span style="color: #339933;">,</span>
		<span style="color: #006600; font-style: italic;">// 弹窗宽</span>
		minWidth<span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">,</span>
		<span style="color: #006600; font-style: italic;">// 弹窗高</span>
		minHeight<span style="color: #339933;">:</span> <span style="color: #CC0000;">300</span><span style="color: #339933;">,</span>
		<span style="color: #006600; font-style: italic;">// 弹窗内容</span>
		contents<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// 定义标签一</span>
				id<span style="color: #339933;">:</span> <span style="color: #3366CC;">'localpic'</span><span style="color: #339933;">,</span>
				<span style="color: #3366CC;">'label'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'标签页一'</span><span style="color: #339933;">,</span>
				elements<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
					<span style="color: #009900;">&#123;</span>
						type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'file'</span><span style="color: #339933;">,</span>
						label<span style="color: #339933;">:</span> <span style="color: #3366CC;">'选择文件'</span><span style="color: #339933;">,</span>
						id<span style="color: #339933;">:</span> <span style="color: #3366CC;">'localfile'</span><span style="color: #339933;">,</span>
						required<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
					<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
					<span style="color: #009900;">&#123;</span>
						type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'button'</span><span style="color: #339933;">,</span>
						label<span style="color: #339933;">:</span> <span style="color: #3366CC;">'按钮'</span><span style="color: #339933;">,</span>
						id<span style="color: #339933;">:</span> <span style="color: #3366CC;">'upload'</span><span style="color: #339933;">,</span>
						required<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
					<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// 定义标签二</span>
				id<span style="color: #339933;">:</span> <span style="color: #3366CC;">'photopic'</span><span style="color: #339933;">,</span>
				<span style="color: #3366CC;">'label'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'标签页二'</span><span style="color: #339933;">,</span>
				elements<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
					<span style="color: #009900;">&#123;</span>
						type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'html'</span><span style="color: #339933;">,</span>
						html<span style="color: #339933;">:</span> <span style="color: #3366CC;">'&lt;h2&gt;HTML页面代码，显示富文本及自定义内容&lt;/h2&gt;'</span><span style="color: #339933;">,</span>
					<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		onOk<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			code <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getValueOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cb'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'code'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			lang <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getValueOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cb'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'lang'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			html <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span> <span style="color: #339933;">+</span> escape<span style="color: #009900;">&#40;</span>code<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">// 将内容回写到编辑器</span>
			editor.<span style="color: #660066;">insertHtml</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;div class=<span style="color: #000099; font-weight: bold;">\&quot;</span>brush:&quot;</span> <span style="color: #339933;">+</span> lang <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">+</span> html <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">onLoad</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>放置图标文件，图标文件名为myplugin.png，和两个JS文件放在同级目录。图片大小为16X16像素。</p>
<p>修改显示页面CKEDITOR对应配置</p>

<div class="wp_codebox"><table><tr id="p90552"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p905code52"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> content <span style="color: #339933;">=</span> CKEDITOR.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'content'</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// 启用插件</span>
		extraPlugins <span style="color: #339933;">:</span> <span style="color: #3366CC;">'myplugin'</span><span style="color: #339933;">,</span>
		toolbar <span style="color: #339933;">:</span>
		<span style="color: #009900;">&#91;</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Bold'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Italic'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Underline'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'TextColor'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'BGColor'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Font'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'FontSize'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'JustifyLeft'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JustifyCenter'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JustifyRight'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JustifyBlock'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">'/'</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'NumberedList'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'BulletedList'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Smiley'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Link'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Unlink'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Table'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'RemoveFormat'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #006600; font-style: italic;">// 在工具栏上显示插件按钮</span>
			<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'myplugin'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=905</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smarty的缓存技术</title>
		<link>http://hliang.sinaapp.com/?p=888</link>
		<comments>http://hliang.sinaapp.com/?p=888#comments</comments>
		<pubDate>Mon, 09 Apr 2012 12:26:04 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://hliang.sinaapp.com/?p=888</guid>
		<description><![CDATA[大家应该知道缓存机制能能有效的减轻网站的服务器压力，Smarty模板引擎的一大亮点就是为我们提供了非常简单的缓存操作，下面就让我们学习一下。 首先我们要知道Smarty缓存机制分为全局缓存，部分缓存，局部缓存三种，我们一一介绍。 1、全局缓存 顾名思义，全局缓存就是为整个网站的全部页面都生成缓存页面。 首先我们要操作smarty的配置文件，开启缓存，指定缓存文件目录，并设置缓存的存活时间 1 2 3 $smarty-&#62;cache_dir = ‘./cache/’; //设置存放缓存文件的文件夹 $smarty-&#62;caching = 1;//开启缓存 0、FALSE代表关闭&#124;非0数字、TRUE代表开启 $smarty-&#62;cache_lifetime = 3600//单位为秒(如果填写-1为永不过期) 接下来我们要去具体的php页面设置与之对应的具体缓存文件的名字 1 2 $url=md5&#40;$_SERVER&#91;'REQUEST_URI'&#93;&#41;;//将当前页面的URL(包含?后面的所有参数)进行md5加密 $smarty-&#62;display&#40;‘list2.html’,$url&#41;;//设置缓存文件名 需要注意的是： $smarty->display(‘与之对应的模板文件名’,'缓存文件名的补充部分’)这个方法。 第二个参数不是必须的，如果不写的话，缓存文件名就是讲过加密处理的模板文件名。 但是这样会碰到一个比较棘手的问题： http://localhost/1.10/sm/list2.php?lan=1 http://localhost/1.10/sm/list2.php?lan=2 http://localhost/1.10/sm/list2.php?lan=3 3个URL对应应该的不同的内容，但是生成的缓存文件名都是list2.html加密后的结果。 这就会导致用户想要查询的是不同的内容，访问的却是同一个缓存文件。 所以建议加上一个辅助参数，将访问url(包含?后面的所有参数)md5加密是作者比较推荐的一种。 2、部分缓存 首先了解什么叫部分缓存，其实就是指定一些文件生成缓存文件，而非网站的全部文件。 了解了需要达到的效果，接下来我们就来具体操作 操作之前，我们先要强调一个概念： 部分缓存的实质其实是部分不缓存，也就是说不是指定那些文件生成缓存，而是指定具体一些文件不生成缓存 假设有3个文件： 1.php //需要缓存 2.php //需要缓存 3.php //不需要缓存 在1.php/2.php文件中还是照旧写上$smarty->display(‘与之对应的模板文件名’,’缓存文件名的补充部分’)这个方法。 但在3.php中我们要特别指明不需要生成缓存，具体的方法是： 1 $smarty-&#62;clear_cache&#40;‘与之对应的模板文件名’&#41;//写在$smarty-&#62;display(‘与之对应的模板文件名’)之前还是之后都可以 当然$smarty->display(‘与之对应的模板文件名’)还是要写，本来就不想生成缓存，第二个参数也就不需要了。 1 $smarty-&#62;clear_cache&#40;&#41;和$smarty-&#62;display&#40;&#41;的参数一定要写成一致的 3、局部缓存 首先让我们了解下局部缓存的意思，就是指定同一页面下的某些局部地方生成缓存。 [...]]]></description>
			<content:encoded><![CDATA[<p>大家应该知道缓存机制能能有效的减轻网站的服务器压力，Smarty模板引擎的一大亮点就是为我们提供了非常简单的缓存操作，下面就让我们学习一下。</p>
<p>首先我们要知道Smarty缓存机制分为全局缓存，部分缓存，局部缓存三种，我们一一介绍。<span id="more-888"></span></p>
<p><strong>1、全局缓存</strong></p>
<p>顾名思义，全局缓存就是为整个网站的全部页面都生成缓存页面。</p>
<p>首先我们要操作smarty的配置文件，开启缓存，指定缓存文件目录，并设置缓存的存活时间</p>

<div class="wp_codebox"><table><tr id="p88858"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p888code58"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache_dir</span> <span style="color: #339933;">=</span> ‘<span style="color: #339933;">./</span>cache<span style="color: #339933;">/</span>’<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//设置存放缓存文件的文件夹</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">caching</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//开启缓存 0、FALSE代表关闭|非0数字、TRUE代表开启</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache_lifetime</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3600</span><span style="color: #666666; font-style: italic;">//单位为秒(如果填写-1为永不过期)</span></pre></td></tr></table></div>

<p>接下来我们要去具体的php页面设置与之对应的具体缓存文件的名字</p>

<div class="wp_codebox"><table><tr id="p88859"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p888code59"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$url</span><span style="color: #339933;">=</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//将当前页面的URL(包含?后面的所有参数)进行md5加密</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display</span><span style="color: #009900;">&#40;</span>‘list2<span style="color: #339933;">.</span>html’<span style="color: #339933;">,</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//设置缓存文件名</span></pre></td></tr></table></div>

<p>需要注意的是：</p>
<p>$smarty->display(‘与之对应的模板文件名’,'缓存文件名的补充部分’)这个方法。</p>
<p>第二个参数不是必须的，如果不写的话，缓存文件名就是讲过加密处理的模板文件名。</p>
<p>但是这样会碰到一个比较棘手的问题：</p>
<p>http://localhost/1.10/sm/list2.php?lan=1</p>
<p>http://localhost/1.10/sm/list2.php?lan=2</p>
<p>http://localhost/1.10/sm/list2.php?lan=3</p>
<p>3个URL对应应该的不同的内容，但是生成的缓存文件名都是list2.html加密后的结果。</p>
<p>这就会导致用户想要查询的是不同的内容，访问的却是同一个缓存文件。</p>
<p>所以建议加上一个辅助参数，将访问url(包含?后面的所有参数)md5加密是作者比较推荐的一种。</p>
<p><strong>2、部分缓存</strong></p>
<p>首先了解什么叫部分缓存，其实就是指定一些文件生成缓存文件，而非网站的全部文件。</p>
<p>了解了需要达到的效果，接下来我们就来具体操作</p>
<p>操作之前，我们先要强调一个概念：</p>
<p>部分缓存的实质其实是部分不缓存，也就是说不是指定那些文件生成缓存，而是指定具体一些文件不生成缓存</p>
<p>假设有3个文件：</p>
<p>1.php //需要缓存</p>
<p>2.php //需要缓存</p>
<p>3.php //不需要缓存</p>
<p>在1.php/2.php文件中还是照旧写上$smarty->display(‘与之对应的模板文件名’,’缓存文件名的补充部分’)这个方法。</p>
<p>但在3.php中我们要特别指明不需要生成缓存，具体的方法是：</p>

<div class="wp_codebox"><table><tr id="p88860"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p888code60"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clear_cache</span><span style="color: #009900;">&#40;</span>‘与之对应的模板文件名’<span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">//写在$smarty-&gt;display(‘与之对应的模板文件名’)之前还是之后都可以</span></pre></td></tr></table></div>

<p>当然$smarty->display(‘与之对应的模板文件名’)还是要写，本来就不想生成缓存，第二个参数也就不需要了。</p>

<div class="wp_codebox"><table><tr id="p88861"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p888code61"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clear_cache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>和<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>的参数一定要写成一致的</pre></td></tr></table></div>

<p><strong>3、局部缓存</strong></p>
<p>首先让我们了解下局部缓存的意思，就是指定同一页面下的某些局部地方生成缓存。</p>
<p>同样的在这里我们也要把思路反转一下。</p>
<p>其实不是指定哪些局部生成缓存，而是哪些局部不生成缓存(这和部分缓存的操作思想是类似的)。</p>
<p>话不多说，先举一个实例</p>
<p>1.php</p>

<div class="wp_codebox"><table><tr id="p88862"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p888code62"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$time</span><span style="color: #339933;">=</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assign</span><span style="color: #009900;">&#40;</span>‘<span style="color: #990000;">time</span>’<span style="color: #339933;">,</span><span style="color: #000088;">$lanmuarr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> insert_timeget<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: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display</span><span style="color: #009900;">&#40;</span>’<span style="color: #cc66cc;">1</span><span style="color: #339933;">.</span>html’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>1.html</p>
<p>{$time}</p>
<p>//开启缓存后，重复刷新这个不会变</p>
<p>{insert name=’timeget’}</p>
<p>//开启缓存后，重复刷新这个会变</p>
<p>看懂了这个例子我们来解释下其中的原理</p>
<p>在PHP中我们只要定义了</p>
<p>函数名为insert_自定义补充名的自定义函数，在其中返回的值，不需要assign()方法传递，就能直接在模板页面中以{insert name=’自定义补充名’}的方式调用，同时不会受到缓存的影响，而实时刷新</p>
<p>好了到这里我们关于smarty的三种缓存方式就全部讲解完了，有兴趣的朋友可以自己试验下不同的效果。</p>
]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=888</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.php</title>
		<link>http://hliang.sinaapp.com/?p=879</link>
		<comments>http://hliang.sinaapp.com/?p=879#comments</comments>
		<pubDate>Tue, 27 Mar 2012 07:17:16 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.ixcv.com/?p=879</guid>
		<description><![CDATA[Evented I/O for PHP [ GitHub ] Example HTTP server 1 2 3 4 5 6 7 &#60;?php $http = new node_http&#40;&#41;; $http-&#62;listen&#40;8080, function&#40;$request, $response&#41; &#123; $response-&#62;end&#40;&#34;yay, super awesome response&#34;&#41;; &#125;&#41;; nodephp_run&#40;&#41;; ?&#62; To build: First build nodephp as a php module 1 2 make sudo make install Then you must add the following line [...]]]></description>
			<content:encoded><![CDATA[<p>Evented I/O for PHP [ <a href="https://github.com/JosephMoniz/node.php" target="_blank">GitHub</a> ]</p>
<h2>Example HTTP server</h2>

<div class="wp_codebox"><table><tr id="p87967"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p879code67"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$http</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> node_http<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$http</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">listen</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8080</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span> <span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;yay, super awesome response&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
nodephp_run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>To build:</h2>
<p>First build nodephp as a php module</p>

<div class="wp_codebox"><table><tr id="p87968"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p879code68"><pre class="shell" style="font-family:monospace;">make
sudo make install</pre></td></tr></table></div>

<p>Then you must add the following line to your php.ini</p>

<div class="wp_codebox"><table><tr id="p87969"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p879code69"><pre class="php" style="font-family:monospace;">extension <span style="color: #339933;">=</span> nodephp<span style="color: #339933;">.</span>so</pre></td></tr></table></div>

<p>Now you can go and run the example script</p>

<div class="wp_codebox"><table><tr id="p87970"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p879code70"><pre class="shell" style="font-family:monospace;">php src/test.php</pre></td></tr></table></div>

<p>Now if you point your browser to 127.0.0.1:8080 you should see the response being served by the test script via nodephp</p>
]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=879</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10个实用的Django建议</title>
		<link>http://hliang.sinaapp.com/?p=872</link>
		<comments>http://hliang.sinaapp.com/?p=872#comments</comments>
		<pubDate>Mon, 26 Mar 2012 02:56:02 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.ixcv.com/?p=872</guid>
		<description><![CDATA[Django 作为一个杰出的Python开源框架，或许得不到和其它流行框架如Rails这样多的赞美，但是它和其他框架一样精炼，非常注重DRY(Don’t Repeat Yourself)原则、组件的重用性,通过自动化过程使编码更简洁。 如果在Django项目中能够灵活使用某些方法和技巧的话，它将大大加快软件开发的速度同时避免很多头疼的事。作者在下面列举了几点，这些方法由浅入深，可以帮助任何级别的程序员更加熟练的使用Django。 1、 在配置中使用相对路径 某些原因使得项目可能常常会被来回的迁移。如果没有事先规划好这种可能性的话这绝对是一个棘手的问题。Rob Hudson 有一个极好的技巧能够确保你的Django项目在部署过程中能够轻松的来回迁移。仅仅只要编写几行代码在你的配置文件(settings.py)中。 1 2 3 4 5 6 import os BASE_DIR = os.path.dirname&#40;os.path.abspath&#40;__file__&#41;&#41; &#160; TEMPLATE_DIRS = &#40; BASE_DIR + '/templates', &#41; 2、 使用{%url%}标签 尽可能使用向后兼容的{%url%}标签来替换硬编码形式的href，与使用绝对路径的url(当然最好不要这样做) 一样达到相同的效果。你的Django项目迁移起来，那些链接也不会有影响。（译者注：比如说我们有一个views.about函数指向about页面r’^about/$’，就可以{% url views.about as about_url %}然后用{{about_url}}这个变量来代替绝对URL地址）尽管它还不是最高级的技巧，但是它确实值得你应用于Django项目中。 3、 尝试把Django admin应用到PHP项目中 Django最伟大的特性之一就是已经成为Django的核心功能的用户验证系统。它易安装，主要用于用户认证和其它一些必要的配置。这个酷毙了的用户系统甚至被建议应用到你的PHP项目中去，这里有一边Jeff Croft 关于为什么Django能够作为任何语言任何应用中的系统管理模块的一个很好的解决方案。 4、 使用独立的媒体服务器 在开发环境中把静态文件放在与Django项目所在的同一台服务器中问题并不大，但是却不要使用在生产环境中，为什么？效率问题。Jacobian.org给出了一个合理的解释。通过一台独立的服务器来处理静态文件，性能将得到有效的提升，如果不想买服务器的话，那么使用Amazon S3相对来更便宜。 5、 使用Debugger工具条 调试工具对任何一种语言来说都是不可或缺的.他们能够加快开发的速度,指出潜在的缺陷. Rob Hudson开发了一个对开发人员非常有用django调试工具。 6、 使用Django单元测试 [...]]]></description>
			<content:encoded><![CDATA[<p>Django 作为一个杰出的Python开源框架，或许得不到和其它流行框架如Rails这样多的赞美，但是它和其他框架一样精炼，非常注重DRY(Don’t Repeat Yourself)原则、组件的重用性,通过自动化过程使编码更简洁。</p>
<p>如果在Django项目中能够灵活使用某些方法和技巧的话，它将大大加快软件开发的速度同时避免很多头疼的事。作者在下面列举了几点，这些方法由浅入深，可以帮助任何级别的程序员更加熟练的使用Django。</p>
<p><strong>1、 在配置中使用相对路径</strong></p>
<p>某些原因使得项目可能常常会被来回的迁移。如果没有事先规划好这种可能性的话这绝对是一个棘手的问题。Rob Hudson 有一个极好的技巧能够确保你的Django项目在部署过程中能够轻松的来回迁移。仅仅只要编写几行代码在你的配置文件(settings.py)中。</p>

<div class="wp_codebox"><table><tr id="p87272"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p872code72"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
BASE_DIR = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">dirname</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">abspath</span><span style="color: black;">&#40;</span>__file__<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
TEMPLATE_DIRS = <span style="color: black;">&#40;</span>
    BASE_DIR + <span style="color: #483d8b;">'/templates'</span>,
<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p><span id="more-872"></span></p>
<p><strong>2、 使用{%url%}标签</strong></p>
<p>尽可能使用向后兼容的{%url%}标签来替换硬编码形式的href，与使用绝对路径的url(当然最好不要这样做) 一样达到相同的效果。你的Django项目迁移起来，那些链接也不会有影响。（译者注：比如说我们有一个views.about函数指向about页面r’^about/$’，就可以{% url views.about as about_url %}然后用{{about_url}}这个变量来代替绝对URL地址）尽管它还不是最高级的技巧，但是它确实值得你应用于Django项目中。</p>
<p><strong>3、 尝试把Django admin应用到PHP项目中</strong></p>
<p>Django最伟大的特性之一就是已经成为Django的核心功能的用户验证系统。它易安装，主要用于用户认证和其它一些必要的配置。这个酷毙了的用户系统甚至被建议应用到你的PHP项目中去，这里有一边Jeff Croft 关于为什么Django能够作为任何语言任何应用中的系统管理模块的一个很好的解决方案。</p>
<p><strong>4、 使用独立的媒体服务器</strong></p>
<p>在开发环境中把静态文件放在与Django项目所在的同一台服务器中问题并不大，但是却不要使用在生产环境中，为什么？效率问题。Jacobian.org给出了一个合理的解释。通过一台独立的服务器来处理静态文件，性能将得到有效的提升，如果不想买服务器的话，那么使用Amazon S3相对来更便宜。</p>
<p><strong>5、 使用Debugger工具条</strong></p>
<p>调试工具对任何一种语言来说都是不可或缺的.他们能够加快开发的速度,指出潜在的缺陷. Rob Hudson开发了一个对开发人员非常有用django调试工具。</p>
<p><strong>6、 使用Django单元测试</strong></p>
<p>利用单元测试确保你代码的改变和预期的一样，而不会破坏任何老的代码，以便向后兼容。Django一个强大的特性就是他能极其简单地写单元测试。Django也可直接使用python的文本测试和单元测试。Django的文档提供了一个详细的教程和样例代码关于怎样做单元测试使得代码正确地运行，以及去除讨厌的bug</p>
<p><strong>7、 使用速查卡</strong></p>
<p>这里有两页厚的速查卡，在 Django文档中你可能翻来覆去要找半天的东西在这里一目了然。它包含如下几个主题</p>
<p>模板：</p>
<p>模板标签及可选项</p>
<p>模板过滤器及可选项</p>
<p>日期格式化语法快速查阅</p>
<p>模型：</p>
<p>域和及选项</p>
<p>常用域的可选项</p>
<p>元类型可选项</p>
<p>模型管理可选项</p>
<p>表单：</p>
<p>域和可选项</p>
<p>常用域可选项</p>
<p>标准错误消息键值</p>
<p><strong>8、使用Django-chunks</strong></p>
<p>除了使用Django的富文本编辑器创建块更容易之外，Django-chunks同样是用于模板中，这是重用代码块的必不可少的工具。</p>
<p><strong>9、 使用Memcache</strong></p>
<p>如果性能在你的Django项目中已经成为一个棘手的问题，那么你将需要使用一些缓存策略。然而Django为缓存提供很多的选择。目前最好的无疑是Memcache,用Django安装memcache非常地简单，如果你使用cmemcache模块的时候。只要模块安装完成后，你仅仅修改一行配置项，你的Django页面变得轻快起来。</p>
<p><strong>10、使用Django，心动不如行动</strong></p>
<p>在你阅读完这篇文章后如果你仍然不完全理解Django的强大，在你的下一个项目中使用Django的一个合符情理的理由就是：它能够节省各种不同软件设计的时间。Jeff Croft解释为什么用Django创建一个项目比你自己设计出来的更高效。Django允许你扩展自己的Web站点，不需要担心设计或者代码以及数据库的兼容性，它会工作地很棒。</p>
]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=872</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>简单介绍一下PHP 5.4的新特性</title>
		<link>http://hliang.sinaapp.com/?p=862</link>
		<comments>http://hliang.sinaapp.com/?p=862#comments</comments>
		<pubDate>Fri, 16 Mar 2012 07:58:12 +0000</pubDate>
		<dc:creator>hliang</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.ixcv.com/?p=862</guid>
		<description><![CDATA[1. 实例化时访问类成员 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Human&#123; function __construct&#40;$name&#41;&#123; $this-&#62;name = $name; &#125; public function hello&#40;&#41;&#123; return &#34;Hi &#34; . $this-&#62;name; &#125; &#125; // old style $human = new Human&#40;&#34;ixcv&#34;&#41;; echo $human-&#62;hello&#40;&#41;; &#160; // new cool style echo &#40;new Human&#40;&#34;ixcv&#34;&#41;&#41;-&#62;hello&#40;&#41;; 2. 短数组定义语法 1 2 [...]]]></description>
			<content:encoded><![CDATA[<p>1. 实例化时访问类成员</p>

<div class="wp_codebox"><table><tr id="p86280"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p862code80"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Human<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</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;">name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> hello<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: #0000ff;">&quot;Hi &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// old style</span>
<span style="color: #000088;">$human</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Human<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ixcv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$human</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hello</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;">// new cool style</span>
<span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Human<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ixcv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>2. 短数组定义语法</p>

<div class="wp_codebox"><table><tr id="p86281"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p862code81"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span id="more-862"></span></p>
<p>3. 支持 Class::{expr}() 语法</p>

<div class="wp_codebox"><table><tr id="p86282"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p862code82"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> Human<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ixcv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">new</span> Human<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Peter&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$human</span><span style="color: #009900;">&#41;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$human</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'hello'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>4. 通过数组间接调用方法</p>

<div class="wp_codebox"><table><tr id="p86283"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p862code83"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$f</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> Human<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ixcv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hello'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$f</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>5. Callable typehint</p>

<div class="wp_codebox"><table><tr id="p86284"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p862code84"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> hi<span style="color: #009900;">&#40;</span>callable <span style="color: #000088;">$f</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$f</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
hi<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> Human<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ixcv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hello'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>6. Traits</p>

<div class="wp_codebox"><table><tr id="p86285"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p862code85"><pre class="php" style="font-family:monospace;">trait FlyMutant <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> fly<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: #0000ff;">'I can fly!'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Mutant <span style="color: #000000; font-weight: bold;">extends</span> Human <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">use</span> FlyMutant<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$mutant</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mutant<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Storm&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$mutant</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fly</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>7. 支持数组提领(Array dereferencing support)</p>

<div class="wp_codebox"><table><tr id="p86286"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p862code86"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> data<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: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ixcv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'surname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Ayuso'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> data<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://hliang.sinaapp.com/?feed=rss2&#038;p=862</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

