smarty的有关问题-变量无法在html中显示
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了smarty的有关问题-变量无法在html中显示,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1343字,纯文字阅读大概需要2分钟。
内容图文
![smarty的有关问题-变量无法在html中显示](/upload/InfoBanner/zyjiaocheng/222/f8ced11ff5e14e8f9924d4af0668e695.jpg)
1.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
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 HTML 分享到:
------解决方案--------------------
下载最新的Smarty:http://smarty.php.com/
当前最新版本:2.6.18
解压后将目录中的libs目录重命名为smarty,复制到你的网站目录,同时在网站根目录下建立templates和templates_c两个目录
建立test.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安装成功了!
------解决方案--------------------
确认smarty已经正确的配置好...不知道你的smarty是个什么版本
内容总结
以上是互联网集市为您收集整理的smarty的有关问题-变量无法在html中显示全部内容,希望文章能够帮你解决smarty的有关问题-变量无法在html中显示所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。