当我在Smarty中遇到问题时,我会得到一个肮脏的错误消息。
如何打开调试模式或者如何获得明确的错误信息
这是一个示例错误:
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'list.tpl'' in
H:ServerFrameWorksmartylibssyspluginssmarty_internal_templatebase.php:127
Stack trace: #0 H:ServerFrameWorksmartylibssyspluginssmarty_internal_templatebase.php(374):
Smarty_Internal_TemplateBase->fetch('news/li...', NULL, NULL, NULL, true) #1
H:Servernewslist.php(157): Smarty_Internal_TemplateBase->display('news/li...') #2
H:Servernewsnews.php(24): include('H:Serve...') #3 H:Serversec.php(13):
include('H:Serve...') #4 {main} thrown in
H:ServerFrameWorksmartylibssyspluginssmarty_internal_templatebase.php on line 127
这就是"反向跟踪"或"堆栈跟踪"——它向您显示程序中错误发生的确切位置,并向后跟踪到代码的最外层。
最有用的东西是:
- 第一行是一个相当合理的错误信息:'无法加载模板文件'list.tpl "
- 在提到Smarty内部部件的行之后,您可以看到
H:Servernewslist.php(157)
。所以在你的文件H:Servernewslist.php
的第157行,你要求Smarty渲染模板,这就是错误的来源。
所以在这种情况下,你有一行PHP代码要求Smarty呈现一个不存在的模板。很难想象还能提供更多的信息。