Smarty HTML
1.php<?php
include_once("libs/Smarty.class.php");
$smarty=new Smarty();
$smarty->template_dir="templates";
$smarty->compile_dir="compile";
$smarty->config_dir="config";
$smarty->cache_dir="cache";
$smarty->left_delimiter="{";
$smarty->right_delimiter="}";
?>
2.php
<?php
include ("smarty_include.php");
$name="this is an apple!";
$smarty->assign("abc",$name);
$smarty->display("index.html");
?>
index.html
{$abc}
index里面的$abc无法显示出$name的值
2.php里可以显示出this is an apple!
请问这是为什么
回复讨论(解决方案)
下载最新的Smarty:http://smarty.php.net/ 当前最新版本:2.6.18 解压后将目录中的libs目录重命名为smarty,复制到你的网站目录,同时在网站根目录下建立templates和templates_c两个目录 建立test.php,内容如下: <?php include_once('./Smarty/Smarty.class.php');$smarty = new Smarty(); $smarty -> template_dir = "./templates"; //模板存放目录 $smarty -> compile_dir = "./templates_c"; //编译目录 $smarty -> left_delimiter = "{{"; //左定界符 $smarty -> right_delimiter = "}}"; //右定界符 $smarty -> assign('test','OK'); $smarty -> display('test.html'); ?> 给templates_c权限755 在templates目录下新建test.html: {{$test}} 打开test.php,如果看到OK就说明你的smarty安装成功了!
test.php显示ok,但是test.html却是{{$test}},没有显示值,和之前没有区别。我想知道html文件里怎么显示{{$test}}
确认smarty已经正确的配置好...不知道你的smarty是个什么版本
test.php显示ok,但是test.html却是{{$test}},没有显示值,和之前没有区别。我想知道html文件里怎么显示{{$test}}
有没设置缓存目录的权限
3.1.13和2.6.27版本,都试过了.