一聚教程网:一个值得你收藏的教程网站

热门教程

Warning: Smarty error: unable to read resource

时间:2022-07-02 10:48:13 编辑:袖梨 来源:一聚教程网

今天第一次写smarty就出来这样的提示:Warning: Smarty error: unable to read resource,代码如下

include_once("Smarty/libs/Smarty.class.php");

 $smarty =new Smarty();
 $smarty->template_dir ='Smarty/template';
 $smarty->compile_dir ='Smarty/template_c';
 $smarty->left_delimiter ='<{';
 $smarty->right_delimiter='}>';
 $smarty->assign('first','第一个');
 $smarty->display('one.tpl');
?>

one.tpl文件如下:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/1999/xhtml">


无标题文档


<{include file="head.tpl"}>
 this is my the <{$first}> smarty!
<{include file="bot.tpl"}>

 head.tpl和bot.tpl文件是头部和尾部文件,这个有一点像asp里面的include的调用外部文件的方式,

看上去代码很简单但怎么会出来这种问题呢?仔细查看后发原来是one.tpl 文件没有放到template目录下,为什么一定要放在这个目录下呢?好我们来看上面的一代码, $smarty->template_dir ='Smarty/template';仔细一看才明白 template是设计模板文件所在的目录,因为我one.tpl文件放在根目录所以就会出现这种问题.

我想大家应该也知道问题出现在哪里了吧

热门栏目