Maison > php教程 > php手册 > le corps du texte

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

WBOY
Libérer: 2016-06-06 19:41:21
original
1057 Les gens l'ont consulté

这篇文章主要介绍了ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法,针对ThinkPHP配置文件config.php设置SHOW_RUN_TIME后不能显示运行时间情况下的解决

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

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!