ThinkPHP中SHOW_RUN_TIME不能正常顯示運行時間的解決方法 原創(chuàng)
本文實例講述了ThinkPHP中SHOW_RUN_TIME不能正常顯示運行時間的解決方法。分享給大家供大家參考。具體如下:
在ThinkPHP的config.php中設(shè)置:
可以在模板輸出運行時間,但是有的時候會出現(xiàn)不顯示運行時間的情況。
對此解決方法如下:
打開 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__}'))
{
$runtime = C('SHOW_RUN_TIME')? ''.$this->showTime().'' : '';
$content = str_replace('{__RUNTIME__}', $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,'{__RUNTIME__}'))
{
$content = str_replace('{__RUNTIME__}', $runtime, $content);
}
else
$content .= $runtime;
echo $content;
if(C('SHOW_PAGE_TRACE')) $this->showTrace();
return null;
}else {
return $content;
}
至此問題搞定!
更多關(guān)于thinkPHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《ThinkPHP入門教程》及《ThinkPHP常用方法總結(jié)》
希望本文所述對大家基于ThinkPHP框架的php程序設(shè)計有所幫助。
- tp5(thinkPHP5框架)時間查詢操作實例分析
- 獲取php頁面執(zhí)行時間,數(shù)據(jù)庫讀寫次數(shù),函數(shù)調(diào)用次數(shù)等(THINKphp)
- ThinkPHP中獲取指定日期后工作日的具體日期方法
- thinkPHP+PHPExcel實現(xiàn)讀取文件日期的方法(含時分秒)
- ThinkPHP框架實現(xiàn)的MySQL數(shù)據(jù)庫備份功能示例
- thinkphp3.x連接mysql數(shù)據(jù)庫的方法(具體操作步驟)
- thinkphp下MySQL數(shù)據(jù)庫讀寫分離代碼剖析
- 基于ThinkPHP5框架使用QueryList爬取并存入mysql數(shù)據(jù)庫操作示例
- thinkphp5框架結(jié)合mysql實現(xiàn)微信登錄和自定義分享鏈接與圖文功能示例
- thinkphp5.1框架實現(xiàn)格式化mysql時間戳為日期的方式小結(jié)
tp5.1 框架數(shù)據(jù)庫-數(shù)據(jù)集操作實例分析

