当前位置: 移动技术网 > IT编程>开发语言>PHP > ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法 原创

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

2018年05月01日  | 移动技术网IT编程  | 我要评论

穿网球裙的英语老师,进贤,金庸群侠传x0.6

本文实例讲述了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程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网