php中的Smarty配置

                                            WampServer2.1e-x32

1.下载并解压Smarty.我下载的是Smarty-2.6.26.zip,解压后的目录为:E:/myspace/PHP/Smarty-2.6.26
2.在php.ini中配置如下:
; Windows: "/path1;/path2"
;include_path = ".;c:/php/includes"
include_path = ".;E:/myspace/PHP/Smarty-2.6.26/libs"
3.创建模板目录如下:
  根目录:  E:/myspace/PHP/Smarty_Dirs
  模板目录:E:/myspace/PHP/Smarty_Dirs/templates
            E:/myspace/PHP/Smarty_Dirs/templates_c
  配置目录:E:/myspace/PHP/Smarty_Dirs/configs
  缓存目录:E:/myspace/PHP/Smarty_Dirs/cache
4.在模板目录E:/myspace/PHP/Smarty_Dirs/templates中创建模板index.tpl:
<html>
  <head><title>{$title}{*这个是注释*}</title></head>
  <body>
    {$body|count_words}
    {$body|capitalize}
  </body>
</html>
5.在apache服务器应用目录(E:/myspace/PHP/php_root)中创建Smarty测试目录SmartyTest(E:/myspace/PHP/php_root/SmartyTest).创建测试文件index.php:
<?php
  require("Smarty.class.php");
  $smarty=new Smarty;
  $smarty->template_dir='E:/myspace/PHP/Smarty_Dirs/templates';
  $smarty->config_dir='E:/myspace/PHP/Smarty_Dirs/configs';
  $smarty->cache_dir='E:/myspace/PHP/Smarty_Dirs/cache';
  $smarty->compile_dir='E:/myspace/PHP/Smarty_Dirs/templates_c';
  $smarty->assign("title","Smarty Test");
  $smarty->assign("body","Hello,This is my first smarty test!");
  /*$smarty->assign("title","Smarty测试");
  $smarty->assign("body","Hello,这是我的第一个Smarty测试!");*/
  $smarty->display("index.tpl");
?>
6.启动服务器(注意前面配置后应重启)测试:http://localhost/SmartyTest/index.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值