解決TP中不能正常顯示已耗用時間的方法

來源:互聯網
上載者:User
本文主要介紹了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中如何串連分散式資料庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.