ob_start与require结合在框架中的应用

      发布在:前端技术      评论:0 条评论
<p>一般的使用方法</p><pre class="brush:php;toolbar:false">mysql_close();<br/>ob_start();<br/>require(&quot;themes/&quot;.$cf[&#39;site_themes&#39;].&quot;/search.php&quot;);<br/>$content=ob_get_clean();<br/><br/>echo json_encode([&#39;code&#39;=&gt;1,&#39;content&#39;=&gt;$content]);<br/></pre><p>用于thinphp作为模板文件缓存的方法<br/></p><pre class="brush:php;toolbar:false">$mkey=C(&#39;CNEN&#39;).&#39;homes_product_dopro_&#39;.$var;<br/>$content=S($mkey);<br/> if($content){<br/> exit($content);<br/> }<br/> <br/> <br/> //最后获取模板数据执行后的内容进行数据保存<br/> ob_start();<br/>$this-&gt;display(&#39;index&#39;);<br/> $content=ob_get_clean();<br/> S($mkey,$content,72000);<br/> echo $content;<br/> <br/></pre><p><br/></p>
热门推荐