本文主要介紹了ThinkPHP中SHOW_RUN_TIME不能正常顯示已耗用時間的解決方案,針對ThinkPHP設定檔config.php設定SHOW_RUN_TIME後不能顯示已耗用時間情況下的解決方案,涉及針對ThinkPHP底層源檔案的修改,需要的朋友可以參考下。希望對大家有所協助。
具體如下:
在ThinkPHP的config.php中設定:
'SHOW_RUN_TIME'=>true;
可以在模板輸出已耗用時間,但是有的時候會出現不顯示已耗用時間的情況。
對此解決方案如下:
開啟 ThinkPHP\Lib\Think\Core\View.class.php檔案,
在protected function output($content,$display)方法中
將:
if(C('HTML_CACHE_ON')) HtmlCache::writeHTMLCache($content); if($display) { if(false !== strpos($content,'')) { $runtime = C('SHOW_RUN_TIME')? ''.$this->showTime().'' : ''; $content = str_replace('', $runtime, $content); } echo $content; if(C('SHOW_PAGE_TRACE')) $this->showTrace(); return null;}else { return $content;}
改為:
if(C('HTML_CACHE_ON')) HtmlCache::writeHTMLCache($content); if($display) { $runtime = C('SHOW_RUN_TIME')? ''.$this->showTime().'' : ''; if(false !== strpos($content,'')) { $content = str_replace('', $runtime, $content); } else $content .= $runtime; echo $content; if(C('SHOW_PAGE_TRACE')) $this->showTrace(); return null;}else { return $content;}
相關推薦:
TP5之Auth許可權管理執行個體
thinkphp3.2中替換入口檔案
Thinkphp中如何串連分散式資料庫