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

2022-11-06百科教程217304

本文实例讲述了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;
}

改为:

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

至此问题搞定!

更多关于thinkphp相关内容感兴趣的读者可查看本站专题:《thinkphp入门教程》及《thinkphp常用方法总结》

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

本文地址:https://www.ufcn.cn/it/786286.html

如非特殊说明,本站内容均来自于网友自主分享,概不代表本站观点,如有任何问题我们都将在收到反馈后的第一时间进行处理!