【发布时间】:2014-05-17 11:26:11
【问题描述】:
致命错误:未捕获--Smarty:无法加载模板文件 'H.tpl'
你好, 当我尝试运行一个聪明的程序时,我会遇到这个胎儿错误。我不知道如何消除这个错误。 我创建了两个文件,一个用于 .php,另一个用于 .tpl
PHP 文件: HelloWorld.php
//This is a simple comment use in php file
require './libs/Smarty.class.php';//require function includes Smarty class
require 'demo/templates/H.tpl';
$smarty=new Smarty;// instantiates an object $smarty of class Smarty
$smarty->caching =true;//enable the caching
$smarty->assign ('name', 'hello world');//used to assign values to the templates
$smarty->display ('H.tpl');//this is used to display the template
?>
TPL 文件: H.tpl
<html>
<head>
<title>My first Smarty program</title>
</head>
<body>
{*This is a comment line of smarty *}
{$name}{*Smarty will replace the assigned content *}
</body>
</html>
【问题讨论】:
-
它说它找不到 H.tpl - 检查你的路径和文件是否存在,PHP 等可以读取等等等等。
-
使用 smarty 前必须配置模板目录
-
默认情况下 smarty 模板在模板目录中。所以你应该把文件 H.tpl 放到这个目录中
-
你创建了templates_c吗?此文件夹的写入权限?