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

Solution to the problem that SHOW_RUN_TIME cannot display the running time properly in ThinkPHP Original, thinkphprun_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:07:34977browse

The solution to the problem that SHOW_RUN_TIME in ThinkPHP cannot display the running time normally. Original, thinkphprun

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1060098.htmlTechArticleThe solution to the problem that SHOW_RUN_TIME in ThinkPHP cannot display the running time normally. Original, thinkphprun This article tells an example of the problem that SHOW_RUN_TIME in ThinkPHP cannot display normally. Runtime workaround. ...
Statement:
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