In ThinkPHP, SHOW_RUN_TIME cannot display the running time properly. Solution: Original, thinkphprun_PHP tutorial

Source: Internet
Author: User
ThinkPHP SHOW_RUN_TIME does not display the running time properly. the solution is original, thinkphprun. In ThinkPHP, the solution of SHOW_RUN_TIME cannot display the running time normally is original. thinkphprun this article describes how to display the running time normally in ThinkPHP SHOW_RUN_TIME. In ThinkPHP, SHOW_RUN_TIME cannot display the running time properly. Solution: Original, thinkphprun

The example in this article describes how SHOW_RUN_TIME in ThinkPHP cannot display the running time properly. Share it with you for your reference. The details are as follows:

Set in config. php of ThinkPHP:
The code is as follows: 'show _ RUN_TIME '=> true;
You can output the running time in the template, but sometimes the running time is not displayed.

The solution is as follows:

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

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;}

Changed:

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;}

Now the problem is solved!

I hope this article will help you design php programs based on the ThinkPHP framework.

Original Author, thinkphprun this article describes how to solve the problem that SHOW_RUN_TIME in ThinkPHP cannot display the running time properly ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.