学习 PHP模板引擎Smarty入门使用 时出错提示:Smarty.class.php on line 1095

来源:百度知道 编辑:UC知道 时间:2024/09/22 07:24:59
我在学习 PHP模板引擎Smarty入门使用 时都是按照教程里讲的做的,但在执行index.php时还是提示:Warning: Smarty error: u

nable to read resource: "index.htm" in D:\wamp\www\moban\smarty\Smarty.class.php on line 1095

不知道是smarty出了问题还是程序编错了,请大家帮我看一下。

111111111111111111111111111111111111111111111111111111111111111111111111111111111

首先编一个配置文件:smarty_inc.php (我是从教程里复制过来的,另外该新建的路径文件我也建了)。

<?php

include_once("Smarty/Smarty.class.php"); //包含smarty类文件

$smarty = new Smarty(); //建立smarty实例对象$smarty

$smarty->config_dir="Smarty/Config_File.class.php"; // 目录变量

$smarty->caching=false; //是否使用缓存,项目在调试期间,不建议启用缓存

$smarty->template_dir = "./templates"; //设置模板目录

$smarty->compile_dir = "./templates_c"; //设置编译目录

$smarty->cache_dir = "./smarty_cache"; //缓存文件夹

//-----------------------------------------

不能“读”取资源 index.htm
smarty读模板动作失败,原因有3
1.index.htm没有读权限,看你新手,应该在win下,排除这个原因
2.没有模板文件不存在,index.htm不存在,这个你自己知道,你肯定建立了这么一个模板
3.模板路径错误,这是你的症结
当你$tpl = new Smarty;之后,推荐打印一下echo $tpl->template_dir;
看看你的index.htm在不在这个目录下