
学习 PHP模板引擎Smarty入门使用 时出错提示:Smarty.class.php on line 1095
我在学习PHP模板引擎Smarty入门使用时都是按照教程里讲的做的,但在执行index.php时还是提示:Warning:Smartyerror:unabletoread...
我在学习 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"; //缓存文件夹
//----------------------------------------------------
//左右边界符,默认为{},但实际应用当中容易与JavaScript相冲突
//----------------------------------------------------
$smarty->left_delimiter = "{";
$smarty->right_delimiter = "}";
?>
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111
22222222222222222222222222222222222222
第二步建一个index.php文件
<?php
include ("smarty_inc.php");
$name="php100中文网站";
$smarty->assign("title",$name);
$smarty->display("index.htm");
?>
22222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
第三步要建一个index.htm文件
<html>
<b>{$title}</b>
</html>
33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
写好之后我执行index.php文件是却提示:
Warning: Smarty error: unable to read resource: "index.htm" in D:\wamp\www\moban\smarty\Smarty.class.php on line 1095
不知道问题究竟出在哪儿! 展开
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"; //缓存文件夹
//----------------------------------------------------
//左右边界符,默认为{},但实际应用当中容易与JavaScript相冲突
//----------------------------------------------------
$smarty->left_delimiter = "{";
$smarty->right_delimiter = "}";
?>
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111
22222222222222222222222222222222222222
第二步建一个index.php文件
<?php
include ("smarty_inc.php");
$name="php100中文网站";
$smarty->assign("title",$name);
$smarty->display("index.htm");
?>
22222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
第三步要建一个index.htm文件
<html>
<b>{$title}</b>
</html>
33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
写好之后我执行index.php文件是却提示:
Warning: Smarty error: unable to read resource: "index.htm" in D:\wamp\www\moban\smarty\Smarty.class.php on line 1095
不知道问题究竟出在哪儿! 展开
展开全部
不能“读”取资源 index.htm
smarty读模板动作失败,原因有3
1.index.htm没有读权限,看你新手,应该在win下,排除这个原因
2.没有模板文件不存在,index.htm不存在,这个你自己知道,你肯定建立了这么一个模板
3.模板路径错误,这是你的症结
当你$tpl = new Smarty;之后,推荐打印一下echo $tpl->template_dir;
看看你的index.htm在不在这个目录下
smarty读模板动作失败,原因有3
1.index.htm没有读权限,看你新手,应该在win下,排除这个原因
2.没有模板文件不存在,index.htm不存在,这个你自己知道,你肯定建立了这么一个模板
3.模板路径错误,这是你的症结
当你$tpl = new Smarty;之后,推荐打印一下echo $tpl->template_dir;
看看你的index.htm在不在这个目录下

2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询