我这个smarty配置怎么了
时间:2011-04-11
来源:互联网
目录结构如下: smarty_pro1
---libs
---config
---templates (这里放了个,index.tpl)
---templates_c
---cache
index.php
index.php 里的内容为
<?php
define('SMARTY_PATH','../smarty_pro1/');
include_once(SMARTY_PATH.'libs/Smarty.class.php');
$smarty=new Smarty();
$smarty->template_dir= SMARTY_PATH.'templates/';
$smarty->compile_dir= SMARTY_PATH.'templates_c/';
$smarty->config_dir= SMARTY_PATH.'configs/';
$smarty->cache_dir= SMARTY_PATH.'cache/';
$smarty->left_delimiter='{';
$smarty->right_delimiter='}';
$smarty->assign('title','测试一下');
$smarty->assign('content','内容');
$smarty->display('index.tpl');
?>
index.tpl内容为
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>{ $title }</title>
</head>
<body>
{ $content }
</body>
</html>
为什么结果 这里面的两个变量都没有得到值啊,搞了好久也没搞好,是什么问题啊?
---libs
---config
---templates (这里放了个,index.tpl)
---templates_c
---cache
index.php
index.php 里的内容为
<?php
define('SMARTY_PATH','../smarty_pro1/');
include_once(SMARTY_PATH.'libs/Smarty.class.php');
$smarty=new Smarty();
$smarty->template_dir= SMARTY_PATH.'templates/';
$smarty->compile_dir= SMARTY_PATH.'templates_c/';
$smarty->config_dir= SMARTY_PATH.'configs/';
$smarty->cache_dir= SMARTY_PATH.'cache/';
$smarty->left_delimiter='{';
$smarty->right_delimiter='}';
$smarty->assign('title','测试一下');
$smarty->assign('content','内容');
$smarty->display('index.tpl');
?>
index.tpl内容为
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>{ $title }</title>
</head>
<body>
{ $content }
</body>
</html>
为什么结果 这里面的两个变量都没有得到值啊,搞了好久也没搞好,是什么问题啊?
作者: tangyong23 发布时间: 2011-04-11
默认标签就是{},删除这两句看看,
$smarty->left_delimiter='{';
$smarty->right_delimiter='}';
一般有问题都应该先看看错误提示是什么,smarty类的错误提示还是比较完整的。
如果还不行,下载最新版http://www.smarty.net/download,smarty3.0.7
不可能没有值的,其实那些目录都不用指定。SMARTY会自动创建!templates,templates_c/,如果设置了cache,还会自动在PHP文件下建立cache.
$smarty->left_delimiter='{';
$smarty->right_delimiter='}';
一般有问题都应该先看看错误提示是什么,smarty类的错误提示还是比较完整的。
如果还不行,下载最新版http://www.smarty.net/download,smarty3.0.7
不可能没有值的,其实那些目录都不用指定。SMARTY会自动创建!templates,templates_c/,如果设置了cache,还会自动在PHP文件下建立cache.
作者: falizixun2 发布时间: 2011-04-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28