<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[[Utf8截取]smarty truncate 截取字符串長度，smarty里嵌入PHP的截取实例。 ]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Thu, 26 Mar 2009 03:06:52 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	一、smarty truncate 截取<br/>從字符串開始處截取某長度的字符.默認是80個。<br/>你也可以指定第二個參數作為追加在截取字符串後面的文本字串.該追加字串被計算在截取長度中。<br/>默認情況下,smarty會截取到一個詞的末尾。<br/>如果你想要精確的截取多少個字符,把第三個參數改為&quot;true&quot; 。<br/><br/><br/>例 截取:<br/><br/>index.php:<br/><br/><div class="code">$smarty = new Smarty;<br/>$smarty-&gt;assign(&#039;articleTitle&#039;, &#039;Two Sisters Reunite after Eighteen Years at Checkout Counter.&#039;);<br/>$smarty-&gt;display(&#039;index.tpl&#039;);</div><br/><br/>index.tpl:<br/><br/><div class="code">&#123;$articleTitle&#125;<br/>&#123;$articleTitle&#124;truncate&#125;<br/>&#123;$articleTitle&#124;truncate:30&#125;<br/>&#123;$articleTitle&#124;truncate:30:&quot;&quot;&#125;<br/>&#123;$articleTitle&#124;truncate:30:&quot;---&quot;&#125;<br/>&#123;$articleTitle&#124;truncate:30:&quot;&quot;:true&#125;<br/>&#123;$articleTitle&#124;truncate:30:&quot;...&quot;:true&#125;</div><br/><br/>輸出結果：<br/><br/><div class="code">Two Sisters Reunite after Eighteen Years at Checkout Counter.<br/>Two Sisters Reunite after Eighteen Years at Checkout Counter.<br/>Two Sisters Reunite after...<br/>Two Sisters Reunite after<br/>Two Sisters Reunite after---<br/>Two Sisters Reunite after Eigh<br/>Two Sisters Reunite after E...</div><br/><br/><br/><br/>在smarty模板中截取指定长度的字符串<br/>在smarty模板中截取指定长度的字符串,可使用truncate这个插件. <br/>用法: <br/>&#123;&#123;$data.value&amp;#124;truncate:28:&#039;...&#039;&#125;&#125; <br/>28个字节14个字数输出，多余部分输出...,一个汉字算两个. <br/>参考中文截取的乱码问题：http://hi.baidu.com/pphu/blog/item/845c3a461663850b6a63e573.html<br/>Smarty中文截取插件：http://hcmjf.bokee.com/viewdiary.204332042.html<br/><br/><br/>二、smarty里嵌入PHP的截取实例:<br/><textarea name="code" class="php" rows="15" cols="100">&lt;&#123;$focus-&gt;user_name&#124;mb_substr:0:21:&#039;utf-8&#039;&#125;&gt;</textarea><br/><textarea name="code" class="php" rows="15" cols="100">&lt;em id=&quot;mingcheng&quot;&gt;&lt;&#123;if $user&#125;&gt;&lt;&#123;$user-&gt;user_name&#124;mb_substr:0:2:&#039;utf8&#039;&#125;&gt;...&lt;&#123;else&#125;&gt;&lt;&#123;$user-&gt;user_name&#125;&gt;&lt;&#123;/if&#125;&gt;&lt;/em&gt;&lt;i class=&quot;icon-down&quot;&gt;&lt;/i&gt;&lt;/a&gt;
</textarea>
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [Utf8截取]smarty truncate 截取字符串長度，smarty里嵌入PHP的截取实例。 ]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>