Home >Backend Development >PHP Tutorial >Solution to the problem that SHOW_RUN_TIME cannot display the running time properly in ThinkPHP Original, thinkphprun_PHP tutorial
The example in this article tells the solution to the problem that SHOW_RUN_TIME in ThinkPHP cannot display the running time properly. Share it with everyone for your reference. The details are as follows:
Set in ThinkPHP’s config.php:
Copy code The code is as follows: 'SHOW_RUN_TIME'=>true;
The running time can be output in the template, but sometimes the running time will not be displayed.
The solution to this is as follows:
Open the ThinkPHPLibThinkCoreView.class.php file,
In the protected function output($content,$display) method
Will:
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; }
changed to:
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; }
This problem is solved!
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.