本文主要介绍了thinkphp中show_run_time不能正常显示运行时间的解决方法,针对thinkphp配置文件config.php设置show_run_time后不能显示运行时间情况下的解决方法,涉及针对thinkphp底层源文件的修改,需要的朋友可以参考下。希望对大家有所帮助。
具体如下:
在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 = 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;
}
改为:
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;
}
相关推荐:
tp5之auth权限管理实例
thinkphp3.2中替换入口文件
thinkphp中如何连接分布式数据库
以上就是解决tp中不能正常显示运行时间的方法的详细内容。