window下smarty环境搭建

1.在网上下载最新的smarty文件。

2,解压缩Smarty包,如放在c:/java/php/smarty

 3、找到你的php.ini配置文件(可以通过运行phpinfo()查看此文件路径,但一般都放在系统目录下)修改php.ini的include_path选项,把smarty的库文件路径加上,比如:

   include_path = ".;c:/java/php/smarty"

   提醒一下,php.ini中一共有两处include_path,一处是Unix下使用的,一处是windows下使用的,要修改windows下使用的:

-------------------------------------------------------------

   ; Windows: "\path1;\path2"

   include_path = ".;c:\php4\includes;d:\smarty\libs"

--------------------------------------------------------------

4、重新启动服务,使更改的配置文件生效。

 

5、在你的项目中建一个MySmarty的目录,再在Mysmarty目录下建一个dir目录,并在dir目录下创建configs(存放配置文件)目录,templates(存放模板)目录,cache(存放缓存)目录,templates_c(存放编译后的文件)等四个目录

6、这时候安装工作基本完成,可以进行第一个简单例子的测试:

   在你的网站目录下建立 index.php文件,并且在(网站目录)/MySmarty/dir/templates/下建立index.tpl文件,分别输入以下代码

  index.php

  <?php

   //载入Smarty库

   require('Smarty.class.php');

  

$smarty = new Smarty;   

   //下面的(你的网站目录)用绝对路径,比如d:/intepub/wwwroot

$smarty-    >template_dir = '(你的网站目录)/MySmarty/templates';

$smarty-    >config_dir = '(你的网站目录)/MySmarty/config';

$smarty-    >cache_dir = (你的网站目录)/MySmarty/smarty_cache';

$smarty-    >compile_dir = (你的网站目录)/MySmarty/smarty_templates_c';

   //上面四行为使用Smarty前的必要参数配置

$smarty-    >assign('name','跟17PHP学安装Smarty');

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

?>

  index.tpl

  <html>

  <body>

$name}!   你好,{

  </body>

  </html>

7、运行index.php(当然是在你的web服务器上运行,和运行普通php文件完全一样。)

  http://localhost/index.php

  这时候如果看到下面的输出结果,说明你安装成功了~~~是不是很简单呢?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值