<?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>Hacklog &#187; smarty</title>
	<atom:link href="http://ihacklog.com/cat/php/smarty/feed" rel="self" type="application/rss+xml" />
	<link>http://ihacklog.com</link>
	<description>荒野无灯weblog</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:30:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>使用Smarty时显示程序执行时间的方法</title>
		<link>http://ihacklog.com/php/smarty/how-to-get-the-exution-time-when-use-smarty.html</link>
		<comments>http://ihacklog.com/php/smarty/how-to-get-the-exution-time-when-use-smarty.html#comments</comments>
		<pubDate>Tue, 26 Apr 2011 09:50:12 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[smarty]]></category>
		<category><![CDATA[exution-time]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ihacklog.com/?p=4391</guid>
		<description><![CDATA[当使用Smarty时，似乎没有什么好的方法来实现显示程序执行时间。 WP或者其它程序时都有一个输出程序执行时间的功能，因此，在自己写的程序里，也想实现这一功能。 搜索了一下，发现基本没有这方面的文章。大多数人认为这个没有必要。 本着折腾的精神，开始一行行看Smarty的源码，最终找到一个比较精确计算出程序执行时间的方法。 在程序最开始部分，也就是执行的第一行代码的位置，加上： 1define&#40;'__START_TIME', microtime&#40;TRUE&#41;&#41;; 然后在smar...]]></description>
			<content:encoded><![CDATA[<p>当使用Smarty时，似乎没有什么好的方法来实现显示程序执行时间。<br />
WP或者其它程序时都有一个输出程序执行时间的功能，因此，在自己写的程序里，也想实现这一功能。<br />
搜索了一下，发现基本没有这方面的文章。大多数人认为这个没有必要。<br />
本着折腾的精神，开始一行行看Smarty的源码，最终找到一个比较精确计算出程序执行时间的方法。<br />
在程序最开始部分，也就是执行的第一行代码的位置，加上：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'__START_TIME'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/microtime"><span style="color: #990000;">microtime</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>然后在smarty_internal_template.php的 renderTemplate函数第一个ob_start前面加上：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'__excution_time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><a href="http://www.php.net/microtime"><span style="color: #990000;">microtime</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> __START_TIME<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>完整代码如下：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;public function renderTemplate ()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;resource_object-&gt;usesCompiler) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;mustCompile() &amp;&amp; $this-&gt;compiled_template === null) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;compileTemplateSource();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;smarty-&gt;debugging) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Smarty_Internal_Debug::start_render($this);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_smarty_tpl = $this;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //计算执行时间 by 荒野无灯 20110401<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //__START_TIME 在程序开始时定义<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //调用 ：{nocache}{$smarty.session.__excution_time|string_format:&quot;%.4f&quot;}{/nocache} <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_SESSION['__excution_time']=microtime(TRUE) - __START_TIME;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ob_start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;resource_object-&gt;isEvaluated) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eval(&quot;?&gt;&quot; . $this-&gt;compiled_template);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; include($this-&gt;getCompiledFilepath ()); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // check file dependencies at compiled code<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;smarty-&gt;compile_check) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!empty($this-&gt;properties['file_dependency'])) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;mustCompile = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $resource_type = null;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $resource_name = null;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach ($this-&gt;properties['file_dependency'] as $_file_to_check) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $mtime = filemtime($_file_to_check[0]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;getResourceTypeName($_file_to_check[0], $resource_type, $resource_name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $resource_handler = $this-&gt;loadTemplateResourceHandler($resource_type);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $mtime = $resource_handler-&gt;getTemplateTimestampTypeName($resource_type, $resource_name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // If ($mtime != $_file_to_check[1]) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If ($mtime &gt; $_file_to_check[1]) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;mustCompile = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;mustCompile) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // recompile and render again<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ob_get_clean();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;compileTemplateSource();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ob_start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; include($this-&gt;getCompiledFilepath ());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (is_callable(array($this-&gt;resource_object, 'renderUncompiled'))) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;smarty-&gt;debugging) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Smarty_Internal_Debug::start_render($this);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ob_start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;resource_object-&gt;renderUncompiled($this);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw new SmartyException(&quot;Resource '$this-&gt;resource_type' must have 'renderUncompiled' methode&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;rendered_content = ob_get_clean();<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (!$this-&gt;resource_object-&gt;isEvaluated &amp;&amp; empty($this-&gt;properties['file_dependency'][$this-&gt;templateUid])) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;properties['file_dependency'][$this-&gt;templateUid] = array($this-&gt;getTemplateFilepath(), $this-&gt;getTemplateTimestamp(),$this-&gt;resource_type);<br />
&nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;parent instanceof Smarty_Internal_Template) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;parent-&gt;properties['file_dependency'] = array_merge($this-&gt;parent-&gt;properties['file_dependency'], $this-&gt;properties['file_dependency']);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach($this-&gt;required_plugins as $code =&gt; $tmp1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach($tmp1 as $name =&gt; $tmp) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach($tmp as $type =&gt; $data) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;parent-&gt;required_plugins[$code][$name][$type] = $data;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;smarty-&gt;debugging) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Smarty_Internal_Debug::end_render($this);<br />
&nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; // write to cache when nessecary<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (!$this-&gt;resource_object-&gt;isEvaluated &amp;&amp; ($this-&gt;caching == Smarty::CACHING_LIFETIME_SAVED || $this-&gt;caching == Smarty::CACHING_LIFETIME_CURRENT)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;smarty-&gt;debugging) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Smarty_Internal_Debug::start_cache($this);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;properties['has_nocache_code'] = false; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // get text between non-cached items<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $cache_split = preg_split(&quot;!/\*%%SmartyNocache:{$this-&gt;properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$this-&gt;properties['nocache_hash']}%%\*/!s&quot;, $this-&gt;rendered_content); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // get non-cached items<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; preg_match_all(&quot;!/\*%%SmartyNocache:{$this-&gt;properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$this-&gt;properties['nocache_hash']}%%\*/!s&quot;, $this-&gt;rendered_content, $cache_parts);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $output = ''; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // loop over items, stitch back together<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach($cache_split as $curr_idx =&gt; $curr_split) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // escape PHP tags in template content<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $output .= preg_replace('/(<span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #339933;">|</span><span style="color: #000000; font-weight: bold;">%&gt;</span>|&lt;\?php|&lt;\?|\?&gt;)/', '<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> \<span style="color: #0000ff;">'$1\'; ?&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$curr_split</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache_parts</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$curr_idx</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">properties</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'has_nocache_code'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// remove nocache tags from cache output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;!/\*/?<span style="color: #009933; font-weight: bold;">%%</span>SmartyNocache:<span style="color: #006699; font-weight: bold;">{$this-&gt;properties['nocache_hash']}</span><span style="color: #009933; font-weight: bold;">%%</span>\*/!&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cache_parts</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$curr_idx</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">autoload_filters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'output'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">registered_filters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'output'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> Smarty_Internal_Filter_Handler<span style="color: #339933;">::</span><span style="color: #004000;">runFilter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'output'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// rendering (must be done before writing cache file because of {function} nocache handling)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$_smarty_tpl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/ob_start"><span style="color: #990000;">ob_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/eval"><span style="color: #990000;">eval</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;?&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rendered_content</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ob_get_clean"><span style="color: #990000;">ob_get_clean</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// write cache file content</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">writeCachedContent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;?php if (!$no_render) {?&gt;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$output</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;?php } ?&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">debugging</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Smarty_Internal_Debug<span style="color: #339933;">::</span><span style="color: #004000;">end_cache</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// var_dump('renderTemplate', $this-&gt;has_nocache_code, $this-&gt;template_resource, $this-&gt;properties['nocache_hash'], $this-&gt;parent-&gt;properties['nocache_hash'], $this-&gt;rendered_content);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">has_nocache_code</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">properties</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nocache_hash'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">properties</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nocache_hash'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// replace nocache_hash</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rendered_content</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">{$this-&gt;properties['nocache_hash']}</span>/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">properties</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nocache_hash'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rendered_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">has_nocache_code</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">has_nocache_code</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>这样以后还没完，在同文件buildTemplateFilepath 函数最开始加上上面同样的语句，修改后的函数如下：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* get system filepath to template<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> buildTemplateFilepath <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//计算执行时间 by 荒野无灯 20110401</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//__START_TIME 在程序开始时定义,对于缓存的模板，是不会执行 renderTemplate() 方法的，因此这里再加一次。</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//对于缓存了的模板，getRenderedTemplate() 中会执行 smarty_internal_cacheresource_file.php 中的</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// getCachedContents() ,而 getCachedContents() 会调用 $_template-&gt;getCachedFilepath() 来获取缓存文件路径.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//而 $_template-&gt;getCachedFilepath() 在模板未过期或开启缓存的情况下又必须调用 cache_resource_object-&gt;getCachedFilepath(),而此方法</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//又要调用 $_template-&gt;getTemplateFilepath() ，因此执行终止时间放这里比较合适。基本上是和最终时间很接近了。</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//而此函数又要调用smarty_internal_resource_extends.php的 resource_object-&gt;getTemplateFilepath() </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//调用 ：{nocache}{$smarty.session.__excution_time|string_format:&quot;%.4f&quot;}{/nocache} </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'__excution_time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><a href="http://www.php.net/microtime"><span style="color: #990000;">microtime</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> __START_TIME<span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp;var_dump('here');exit;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resource_name</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// relative file name? </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#41;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template_dir</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$_template_dir</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\', substr($_template_dir, -1)) === false) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_template_dir .= DS;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_filepath = $_template_dir . $file;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (file_exists($_filepath)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $_filepath;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!preg_match('</span><span style="color: #339933;">/</span>^<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>\<span style="color: #339933;">/</span>\\\\<span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z<span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>\<span style="color: #339933;">/</span>\\\\<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #0000ff;">', $_template_dir)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // try PHP include_path<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (($_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath)) !== false) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $_filepath;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; // try absolute filepath<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (file_exists($file)) return $file;<br />
&nbsp; &nbsp; &nbsp; &nbsp; // no tpl file found<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (!empty($this-&gt;smarty-&gt;default_template_handler_func)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!is_callable($this-&gt;smarty-&gt;default_template_handler_func)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw new SmartyException(&quot;Default template handler not callable&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_return = call_user_func_array($this-&gt;smarty-&gt;default_template_handler_func,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array($this-&gt;resource_type, $this-&gt;resource_name, &amp;$this-&gt;template_source, &amp;$this-&gt;template_timestamp, $this));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (is_string($_return)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $_return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } elseif ($_return === true) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $file;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; return false;<br />
&nbsp; &nbsp; }</span></div></td></tr></tbody></table></div>
<p>最后是在模板中显示了：</p>
<div class="codecolorer-container smarty default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="smarty codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #D36900;">&#123;</span>nocache<span style="color: #D36900;">&#125;</span><span style="color: #D36900;">&#123;</span><a href="http://smarty.php.net/%24smarty"><span style="color: #0600FF;"><span style="color: #00aaff;">$smarty</span></span></a>.<span style="color: #006600;">session</span>.__excution_time|string_format:<span style="color: #ff0000;">&quot;%.4f&quot;</span><span style="color: #D36900;">&#125;</span><span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span>nocache<span style="color: #D36900;">&#125;</span> seconds</div></td></tr></tbody></table></div>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=4391";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=4391" title="Permanent Link to 使用Smarty时显示程序执行时间的方法" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=4391</a>
            </p>
             </div><h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2010年03月11日  //  <a href="http://ihacklog.com/php/framework/change-thinkphp-framework-to-support-smarty-template-engine-perfectly.html" title="让thinkphp完美支持smarty模板">让thinkphp完美支持smarty模板</a> (6)</li><li>2009年12月6日  //  <a href="http://ihacklog.com/memory/hacklog/blogshow-a-blog-show-system-based-on-php.html" title="最近折腾blogshow">最近折腾blogshow</a> (8)</li><li>2011年09月3日  //  <a href="http://ihacklog.com/php/markdown-intro.html" title="Markdown 的使用介绍">Markdown 的使用介绍</a> (0)</li><li>2011年08月2日  //  <a href="http://ihacklog.com/php/skills/30-php-best-practices-for-beginners.html" title="给初学者的30条PHP最佳实践">给初学者的30条PHP最佳实践</a> (7)</li><li>2011年08月2日  //  <a href="http://ihacklog.com/php/skills/10-advanced-php-tips-revisited.html" title="10条PHP高级技巧[修正版]">10条PHP高级技巧[修正版]</a> (5)</li><li>2011年07月10日  //  <a href="http://ihacklog.com/software/development-tool/install-cool-theme-for-netbeans-ide.html" title="给NetBeans IDE 换衣服">给NetBeans IDE 换衣服</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/smarty/how-to-get-the-exution-time-when-use-smarty.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>smarty局部缓存技术</title>
		<link>http://ihacklog.com/php/smarty/smarty-partly-cach.html</link>
		<comments>http://ihacklog.com/php/smarty/smarty-partly-cach.html#comments</comments>
		<pubDate>Sun, 13 Dec 2009 16:05:12 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[smarty]]></category>
		<category><![CDATA[缓存技术]]></category>

		<guid isPermaLink="false">http://www.hacklog.cn/?p=3396</guid>
		<description><![CDATA[其实我以前只是听过smarty的大名，并没有使用之。 最近做一个叫BlogShow的程序，想到用smarty来实现代码与表现的分离。于是慢慢边学边用，对它有了一定的了解。 发现smrty 是如此强大与神奇的一个东东，使我对它的好感不亚于对TP. 由于我默认是开启smarty的缓存的，但是在些地方的数据是实时更新或者更新较快的，不宜缓存，这样，局部缓存便有用武之地了。 1，insert 法 定义一个函数显示时间的： 12345function insert_get_current_time&#40;&#41...]]></description>
			<content:encoded><![CDATA[<p>其实我以前只是听过smarty的大名，并没有使用之。<br />
最近做一个叫BlogShow的程序，想到用smarty来实现代码与表现的分离。于是慢慢边学边用，对它有了一定的了解。<br />
发现smrty 是如此强大与神奇的一个东东，使我对它的好感不亚于对TP.<br />
由于我默认是开启smarty的缓存的，但是在些地方的数据是实时更新或者更新较快的，不宜缓存，这样，局部缓存便有用武之地了。<br />
1，insert 法<br />
定义一个函数显示时间的：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> insert_get_current_time<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$timestamp</span><span style="color: #339933;">=</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span>?<a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000088;">$timestamp</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$timeoffset</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #0000ff;">'+8'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$ret</span><span style="color: #339933;">=</span><a href="http://www.php.net/gmdate"><span style="color: #990000;">gmdate</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-n-j g:ia&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$timeoffset</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">3600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>然后在模板中：</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">{insert name=&quot;get_current_time&quot;}</div></td></tr></tbody></table></div>
<p>这样每次打开页面，显示的都是即时时间，而不是缓存的。注意这里的函数名一定要以insert开头，模板中的name与之对应。<br />
这种方法简单，但是如果要显示的内容是一大块的，就不宜使用了。</p>
<p>2，动态block 法</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//部分缓存</span><br />
<span style="color: #000000; font-weight: bold;">function</span> smarty_block_nocache<span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$smarty</span><span style="color: #009900;">&#41;</span><br />
&nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register_block</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'nocache'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'smarty_block_nocache'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>在模板中：</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">{nocache}<br />
{$smarty.now}<br />
{/nocache}</div></td></tr></tbody></table></div>
<p><a href="http://static.ihacklog.com/wp-files/2009/12/smarty_partly_cache.png" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2009/12/smarty_partly_cache-550x205.png" alt="smarty_partly_cache" title="smarty_partly_cache" width="550" height="205" class="alignnone size-medium wp-image-3397" /> </a></p>
<p>这样每次刷新页面，显示的时间都是不同的。</p>
<p>3，插件block 法<br />
在Smarty/plugins目录下建一个文件<br />
block.nocache.php 内容如下：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<span style="color: #000000; font-weight: bold;">function</span> smarty_block_nocache<span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$smarty</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span> <br />
<span style="color: #009900;">&#125;</span> &nbsp;<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>这样做与方法2的效果是一样的，模板中标签也一样。在 php文件中就不必要再register_block了，很方便。</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=3396";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=3396" title="Permanent Link to smarty局部缓存技术" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=3396</a>
            </p>
             </div><h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2011年04月26日  //  <a href="http://ihacklog.com/php/smarty/how-to-get-the-exution-time-when-use-smarty.html" title="使用Smarty时显示程序执行时间的方法">使用Smarty时显示程序执行时间的方法</a> (1)</li><li>2010年03月11日  //  <a href="http://ihacklog.com/php/framework/change-thinkphp-framework-to-support-smarty-template-engine-perfectly.html" title="让thinkphp完美支持smarty模板">让thinkphp完美支持smarty模板</a> (6)</li><li>2009年12月13日  //  <a href="http://ihacklog.com/php/smarty/parameter-3-to-smarty_block_mynocache-expected-to-be-a-reference.html" title="Parameter 3 to smarty_block_mynocache() expected to be a reference">Parameter 3 to smarty_block_mynocache() expected to be a reference</a> (0)</li><li>2009年12月6日  //  <a href="http://ihacklog.com/memory/hacklog/blogshow-a-blog-show-system-based-on-php.html" title="最近折腾blogshow">最近折腾blogshow</a> (8)</li><li>2009年11月27日  //  <a href="http://ihacklog.com/php/smarty/call-to-undefined-method-smarty_internal_resource_filegettemplatetimestamptypename.html" title="Call to undefined method Smarty_Internal_Resource_File::getTemplateTimestampTypeName">Call to undefined method Smarty_Internal_Resource_File::getTemplateTimestampTypeName</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/smarty/smarty-partly-cach.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Parameter 3 to smarty_block_mynocache() expected to be a reference</title>
		<link>http://ihacklog.com/php/smarty/parameter-3-to-smarty_block_mynocache-expected-to-be-a-reference.html</link>
		<comments>http://ihacklog.com/php/smarty/parameter-3-to-smarty_block_mynocache-expected-to-be-a-reference.html#comments</comments>
		<pubDate>Sun, 13 Dec 2009 08:58:47 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://www.hacklog.cn/?p=3392</guid>
		<description><![CDATA[php5.3 下，smarty 3.0b5部分缓存出错，提示错误信息为： Warning: Parameter 3 to smarty_block_mynocache() expected to be a reference, value given in D:\htdocs\project\***\libs\sysplugins\smarty_internal_plugin_handler.php on line 28 定义的部分缓存函数为： 1234function smarty_block_myno...]]></description>
			<content:encoded><![CDATA[<p>php5.3 下，smarty 3.0b5部分缓存出错，提示错误信息为：</p>
<blockquote><p>Warning: Parameter 3 to smarty_block_mynocache() expected to be a reference, value given in D:\htdocs\project\***\libs\sysplugins\smarty_internal_plugin_handler.php on line 28
</p></blockquote>
<p>定义的部分缓存函数为：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> smarty_block_mynocache<span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,&amp;</span><span style="color: #000088;">$smarty</span><span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>此函数在php5.3+ smarty 3.0b4环境下没有任何错误提示（配置php显示所有错误 ),但换用smarty 3.0b5后出现错误了。<br />
根据提示信息，我把函数修改为：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> smarty_block_mynocache<span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span><span style="color: #000088;">$smarty</span><span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>结果与我设想的一样，错误被 KILL 了。<br />
即把引用参数处的&#038;号去除。</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=3392";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=3392" title="Permanent Link to Parameter 3 to smarty_block_mynocache() expected to be a reference" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=3392</a>
            </p>
             </div><h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2011年04月26日  //  <a href="http://ihacklog.com/php/smarty/how-to-get-the-exution-time-when-use-smarty.html" title="使用Smarty时显示程序执行时间的方法">使用Smarty时显示程序执行时间的方法</a> (1)</li><li>2010年03月11日  //  <a href="http://ihacklog.com/php/framework/change-thinkphp-framework-to-support-smarty-template-engine-perfectly.html" title="让thinkphp完美支持smarty模板">让thinkphp完美支持smarty模板</a> (6)</li><li>2009年12月14日  //  <a href="http://ihacklog.com/php/smarty/smarty-partly-cach.html" title="smarty局部缓存技术">smarty局部缓存技术</a> (1)</li><li>2009年12月6日  //  <a href="http://ihacklog.com/memory/hacklog/blogshow-a-blog-show-system-based-on-php.html" title="最近折腾blogshow">最近折腾blogshow</a> (8)</li><li>2009年11月27日  //  <a href="http://ihacklog.com/php/smarty/call-to-undefined-method-smarty_internal_resource_filegettemplatetimestamptypename.html" title="Call to undefined method Smarty_Internal_Resource_File::getTemplateTimestampTypeName">Call to undefined method Smarty_Internal_Resource_File::getTemplateTimestampTypeName</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/smarty/parameter-3-to-smarty_block_mynocache-expected-to-be-a-reference.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Call to undefined method Smarty_Internal_Resource_File::getTemplateTimestampTypeName</title>
		<link>http://ihacklog.com/php/smarty/call-to-undefined-method-smarty_internal_resource_filegettemplatetimestamptypename.html</link>
		<comments>http://ihacklog.com/php/smarty/call-to-undefined-method-smarty_internal_resource_filegettemplatetimestamptypename.html#comments</comments>
		<pubDate>Fri, 27 Nov 2009 14:09:44 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://www.hacklog.cn/?p=3276</guid>
		<description><![CDATA[今天把win下的程序移动到linux下，smarty 报错： Fatal error: Call to undefined method Smarty_Internal_Resource_File::getTemplateTimestampTypeName() in …/lib/Smarty3/sysplugins/smarty_internal_compile_include.php on line 54 简单地删除compile_c和cache目录下的缓存文件，问题解决。 喜欢这篇文章吗?请订阅本站 ...]]></description>
			<content:encoded><![CDATA[<p>今天把win下的程序移动到linux下，smarty 报错：</p>
<blockquote><p>Fatal error: Call to undefined method Smarty_Internal_Resource_File::getTemplateTimestampTypeName() in …/lib/Smarty3/sysplugins/smarty_internal_compile_include.php on line 54</p></blockquote>
<p>简单地删除compile_c和cache目录下的缓存文件，问题解决。</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=3276";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=3276" title="Permanent Link to Call to undefined method Smarty_Internal_Resource_File::getTemplateTimestampTypeName" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=3276</a>
            </p>
             </div><h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2011年04月26日  //  <a href="http://ihacklog.com/php/smarty/how-to-get-the-exution-time-when-use-smarty.html" title="使用Smarty时显示程序执行时间的方法">使用Smarty时显示程序执行时间的方法</a> (1)</li><li>2010年03月11日  //  <a href="http://ihacklog.com/php/framework/change-thinkphp-framework-to-support-smarty-template-engine-perfectly.html" title="让thinkphp完美支持smarty模板">让thinkphp完美支持smarty模板</a> (6)</li><li>2009年12月14日  //  <a href="http://ihacklog.com/php/smarty/smarty-partly-cach.html" title="smarty局部缓存技术">smarty局部缓存技术</a> (1)</li><li>2009年12月13日  //  <a href="http://ihacklog.com/php/smarty/parameter-3-to-smarty_block_mynocache-expected-to-be-a-reference.html" title="Parameter 3 to smarty_block_mynocache() expected to be a reference">Parameter 3 to smarty_block_mynocache() expected to be a reference</a> (0)</li><li>2009年12月6日  //  <a href="http://ihacklog.com/memory/hacklog/blogshow-a-blog-show-system-based-on-php.html" title="最近折腾blogshow">最近折腾blogshow</a> (8)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/smarty/call-to-undefined-method-smarty_internal_resource_filegettemplatetimestamptypename.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

