一、Smarty的安装
1、下载smarty
路径:http://www.smarty.net/download
2、解压到本地,并将其中文件夹libs整体拷贝到php网站目录下并改名为smarty.
如图所示:
3、在网站目录下新建四个文件夹,分别为:Templates,Templates_c,Cache,Config。
其中:
- Templates存放模板文件
- Templates_c存放编译后文件
- Templates存放缓存文件
- Templates存放配置文件
二、SMARTY使用步骤
Step1.加载Smarty模板引擎。
Step2.建立Smarty对象。
Step3.建立Smarty对象的参数。
Step4.在程序中处理变量后,再用Smarty的assign方法将变量置入模板里。
Step5.利用Smarty的display方法将网页秀出。