php对smarty的使用,[ php ] php smarty使用!

1 在你的网站目录下创建一个文件夹,名字任意,假设叫smarty_demo:

2  然后再在这个MySmarty目录下创建2个文件夹,templates和configs。

创建完成之后如下:    (你的网站目录)/smarty_demo/templates (这个目录用来存放模版)

(你的网站目录)/smarty_demo/configs (这个目录用来存放一些配置信息)

3、在smart_demo目录下再创建两个文件夹,名字分别叫:smarty_cache和smarty_templates_c。为什么刚才不一起创建呢?因为这个步骤在原来的官方资料中没有,而我在配置过P中发现,如果没有这两个文件夹,smarty将无法工作,不知道是不是官方资料的smarty版本和目前最新的版本有出入的原因。但是只要配置这两个目录,Smarty便可以顺利工作。因此建议进行配置。

require('smarty/Smarty.class.php');

$smarty = new Smarty;

$smarty->template_dir = 'D:/AppServ/www/smarty_demo/templates/';

$smarty->config_dir = 'D:/AppServ/www/smarty_demo/configs/';

$smarty->cache_dir = 'D:/AppServ/www/smarty_demo/smarty_cache/';

$smarty->compile_dir = 'D:/AppServ/www/smarty_demo/smarty_templates_c/';

$smarty->assign('name','helloword');

$smarty->display('index.tpl');

?>

{$name}!;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值