可以从官方站点下载:http://smarty.php.net/
2、解压缩Smarty包
解压后的文件夹重命名为Smarty,放置在C:\Apache2\include下
3、修改配置文件php.ini的include_path选项,把smarty的库文件路径加上
include_path = “C:\Apache2\include\Smarty\libs”
4、在你的网站目录下创建一个文件夹smarty:
然后再在这个Smarty目录下创建4个文件夹,templates(存放模版)、configs(存放一些配置信息)、template-c(存放编译文件)和cache(存放缓存)。
5、测试:
| //index.php(放在网站目录下) <?php include(”Smarty.class.php”); $smarty = new Smarty; $smarty->template_dir=’网站目录\smarty\templates’; $smarty->config_dir=’网站目录\smarty\configs’; $smarty->cache_dir=’网站目录\smarty\cache’; $smarty->compile_dir=’网站目录\smarty\templates_c’; $smarty->assign(’name’,'xin); $smarty->display(’index.tpl’); ?>
//index.tpl(放在/smarty/templates目录下) |
6、显示:(运行index.php )
| 你好,xin! |
7、注意:
php.ini中一共有两处include_path,一处是Unix下使用的,一处是windows下使用的,要修改windows下使用的
如果不设置include_path,可以直接把Smarty.class.php拷到网站目录


