Home > Backend Development > PHP Tutorial > How to solve the problem that running time cannot be displayed properly in TP

How to solve the problem that running time cannot be displayed properly in TP

*文
Release: 2023-03-18 18:22:01
Original
2070 people have browsed it

This article mainly introduces the solution to the problem that SHOW_RUN_TIME in ThinkPHP cannot display the running time normally. The solution to the problem that the running time cannot be displayed after setting SHOW_RUN_TIME for the ThinkPHP configuration file config.php. It involves the modification of the underlying source file of ThinkPHP. What is needed Friends can refer to it. I hope to be helpful.

The details are as follows:

Set in ThinkPHP's config.php:

'SHOW_RUN_TIME'=>true;
Copy after login

You can output the running time in the template, but sometimes the running time will not be displayed. .

The solution to this is as follows:

Open the ThinkPHP\Lib\Think\Core\View.class.php file,
In protected function output($content,$display ) method
will be changed:

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;
}
Copy after login

to:

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;
}
Copy after login


## Related recommendations:

TP5 Auth permission management example

Replace the entry file in thinkphp3.2

How to connect to a distributed database in Thinkphp

The above is the detailed content of How to solve the problem that running time cannot be displayed properly in TP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template