Windows下安装 Smarty
前提:服务器和php已经安装好并可以正常运行。
下载 Smarty - http://smarty.php.net
解压文件, 重命名 Smarty.x.x.x 为 smarty (出于方便,建议不要把文件放在服务器目录下) 
例如: d:/smarty
运行 phpinfo.php 找到 php.ini 文件的位置
编辑 php.ini的 include_path ,加入smarty的libs的路径。
例如: include_path = ".;d:/smarty/libs"
重启 IIS/Apache
在服务器目录下创建下面两个文件夹:
(wwwroot)/smarty/templates (模板以后放在这里)
(wwwroot)/smarty/configs
在非服务器目录下创建下面两个文件夹:
d:/smarty/templates_c
d:/smarty/cache (这个我目前根据本文的测试,没有用)
设置系统,保证这四个文件是可写的。
在 (wwwroot) 建立 index.php 然后建立 (wwwroot)/smarty/templates/index.tpl ,代码如下:
index.php:
<?php
// load Smarty library
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = ' d:/inetpub/wwwroot/ smarty/templates';
$smarty->config_dir = ' d:/inetpub/wwwroot/ smarty/config';
$smarty->cache_dir = 'd:/smarty/cache';
$smarty->compile_dir = 'd:/smarty/templates_c';
$smarty->assign('name','fish boy!');
$smarty->display('index.tpl');
?>
index.tpl
<html>
<body>
Hello, {$name}!
</body>
</html>
现在在浏览器中打开 index.php
http://webserver/index.php
上面是一个简单的例子,下面建立一个使用class的例子:
smarty_connect.php:
<?php
// load Smarty library
require('Smarty.class.php');
class smarty_connect extends Smarty
{
   function smarty_connect()
   {
        // Class Constructor.
        // These automatically get set with each new instance.
               $this->Smarty();
               $this->template_dir = ' d:/inetpub/wwwroot/ smarty/templates';
               $this->config_dir = ' d:/inetpub/wwwroot/ smarty/config';
               $this->compile_dir = 'd:/smarty/templates_c';
               $this->cache_dir = 'd:/smarty/cache';
               $this->assign('app_name', 'Intranet');
   }
}
?>
index.php:
<?php
require('smarty_connect.php');
$smarty = new smarty_connect;
$smarty->assign('name','Ned');
$smarty->display('index.tpl');
?>
index.tpl:
<html>
<body>
 Hello, {$name}!
</body>
</html>
如果出现错误,请察看php.ini文件是否有错误,include是否正确。
  
注:我自己是把 config templates templates_c 都放到服务器目录下了,而且没有建立 cache 文件夹,程序正常运行。

Windows下安装 Smarty相关推荐

  1. 基于svnserve的SVN服务器(windows下安装与配置)

    基于svnserve的SVN服务器(windows下安装与配置) 关键字: svn 安装SVNserve 从http://subversion.tigris.org/servlets/ProjectD ...

  2. Windows下安装Z3的Python3版

    文章目录 Windows下安装Z3的Python3版 pip 安装(不推荐,很慢) 使用微软官方构建好的DLL(推荐,快速) Windows下安装Z3的Python3版 GitHub官方仓库地址:Z3 ...

  3. 在windows下安装concurrentlua

    concurrentlua的makefile只提供了unix下的版本,如果直接按make里面得拷贝路径安排文件 在windows下是无法凑效的.这里我把我在windows下安装concurrentlu ...

  4. linux/windows下安装scala

    为什么80%的码农都做不了架构师?>>>    一.linux下安装scala 1.保证jdk安装成功,版本在1.5或者更改版本,java和javac均可用. 2.官网下载scala ...

  5. windows下安装cygwin及配置

    windows下安装cygwin及配置 对于使用Windows操作系统作为开发平台同时又喜欢类unix环境的朋友(Windows不是最方便的开发环境),这里是在Cygwin环境下安装Rails的步骤 ...

  6. Redis第一集:Windows下安装Redis和测试

    Redis第一集:Windows下安装Redis和测试 一.资源 Windows下的Redis的下载地址 点击这里即可下载,如果进不去GitHub的话,可以上网搜一下怎么进GitHub,搭个梯子(●ˇ ...

  7. 如何在windows下安装cygwin

    如何在windows下安装cygwin 转载于:https://www.cnblogs.com/zhujiabin/p/5747580.html

  8. 在windows下安装python包管理器pip及使用

      从来没有在Windows下用过pip,今天试了下,原来pip也可以在Windows下安装,使用也和Linux下一样简单. 先从下面的地址下载pip源码: http://pypi.python.or ...

  9. 《Nmap渗透测试指南》—第1章1.2节Windows下安装Nmap

    本节书摘来自异步社区<Nmap渗透测试指南>一书中的第1章1.2节Windows下安装Nmap,作者 商广明,更多章节内容可以访问云栖社区"异步社区"公众号查看. 1. ...

最新文章

  1. 深度学习之反向传播算法
  2. 排序算法之冒泡,选择,插入
  3. 诺基亚 IoT安全白皮书
  4. “当前上下文中不存在名称”解决
  5. 48. Rotate Image
  6. oracle xmltype使用,oracle的xmltype基本使用有哪些呢?
  7. dotnet 从零开始写一个人工智能 网络模型
  8. MATLAB矩阵对称旋转
  9. webpack自动化构建脚本指令npm run dev/build
  10. 几种字符串到byte[] 数组转化为String 的方法
  11. 山寨Facebook的Shimmer效果
  12. #define、typedef与const
  13. 第4章 URL管理器和实现方法
  14. 56.Linux/Unix 系统编程手册(下) -- SOCKET 介绍
  15. 拓端tecdat|Matlab正态分布、历史模拟法、加权移动平均线 EWMA估计风险价值VaR和回测Backtest标准普尔指数 SP500时间序列
  16. 代码审查(咳咳......又降温了啊....!!!!)
  17. 老毛桃u盘装系统linux,老毛桃如何安装iso系统_老毛桃u盘启动安装iso系统教程
  18. 推荐两个适合代码的字体
  19. 10个深度学习软件_关于深度学习的10个问题
  20. 从bam中截取指定位置的 reads 或深度

热门文章

  1. psid mysql_浅识MySQL
  2. Excel导出模板加数据时,下拉框丢失解决方案
  3. 专精特新企业认定条件 这些条件要满足
  4. php5.3不能连接mssql数据库的解决方法
  5. 用java语言实现2020年1月1号到2022年7月3号之间的间隔天数
  6. jQuery仿QQ空间图片查看特效(全屏,放大,缩小,旋转,镜像,鼠标滚轮缩放)
  7. 电子商务的概念及应用
  8. 测试独立显卡显存好坏的软件,显卡显存测试小软件(Artifact Tester)
  9. Facebook广告投放的正确姿势:玩转目标定位
  10. Tensorflow Serving源码详解