如何清除Smarty错误或打开调试开关


How to clear Smarty error or enable debugging

当我在Smarty中遇到问题时,我会得到一个肮脏的错误消息。

如何打开调试模式或者如何获得明确的错误信息

这是一个示例错误:

Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'list.tpl'' in
H:'Server'FrameWork'smarty'libs'sysplugins'smarty_internal_templatebase.php:127 
Stack trace: #0 H:'Server'FrameWork'smarty'libs'sysplugins'smarty_internal_templatebase.php(374):
Smarty_Internal_TemplateBase->fetch('news/li...', NULL, NULL, NULL, true) #1 
H:'Server'news'list.php(157): Smarty_Internal_TemplateBase->display('news/li...') #2 
H:'Server'news'news.php(24): include('H:'Serve...') #3 H:'Server'sec.php(13): 
include('H:'Serve...') #4 {main} thrown in 
H:'Server'FrameWork'smarty'libs'sysplugins'smarty_internal_templatebase.php on line 127

这就是"反向跟踪"或"堆栈跟踪"——它向您显示程序中错误发生的确切位置,并向后跟踪到代码的最外层。

最有用的东西是:

  1. 第一行是一个相当合理的错误信息:'无法加载模板文件'list.tpl "
  2. 在提到Smarty内部部件的行之后,您可以看到H:'Server'news'list.php(157)。所以在你的文件H:'Server'news'list.php的第157行,你要求Smarty渲染模板,这就是错误的来源。

所以在这种情况下,你有一行PHP代码要求Smarty呈现一个不存在的模板。很难想象还能提供更多的信息。