Table of Contents
ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法 原创,thinkphprun
Home php教程 php手册 ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法 原创,thinkphprun

ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法 原创,thinkphprun

Jun 13, 2016 am 08:53 AM
thinkphp Solution

ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法 原创,thinkphprun

本文实例讲述了ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法。分享给大家供大家参考。具体如下:

在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__}'))
  {
    $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;
}

Copy after login

改为:

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

Copy after login

至此问题搞定!

希望本文所述对大家基于ThinkPHP框架的php程序设计有所帮助。

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Printer operation cannot be completed error 0x0000709 Solution Printer operation cannot be completed error 0x0000709 Solution Apr 20, 2024 pm 10:10 PM

Printer operation cannot be completed error 0x0000709 Solution

Methods to solve the problem of Chinese garbled characters in PHP Dompdf Methods to solve the problem of Chinese garbled characters in PHP Dompdf Mar 05, 2024 pm 03:45 PM

Methods to solve the problem of Chinese garbled characters in PHP Dompdf

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

Linux Oops Revealed: Causes of Errors and Solutions Linux Oops Revealed: Causes of Errors and Solutions Mar 20, 2024 am 11:15 AM

Linux Oops Revealed: Causes of Errors and Solutions

What should I do if my Black Shark phone continues to cycle on and off? The solution is revealed! What should I do if my Black Shark phone continues to cycle on and off? The solution is revealed! Mar 25, 2024 am 09:36 AM

What should I do if my Black Shark phone continues to cycle on and off? The solution is revealed!

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

How to install thinkphp

See all articles