smarty:是一个基于php开发的模板引擎。它提供了php和html的模板分离,
简单的讲,目的就是要使用php的程序员同美工分离,使程序员改变程序
的逻辑内容不会影响到美工的页面设计,美工重新修改页面不会影响到
程序员的逻辑,这样在多人合作的项目中尤其重要。
smarty
优点:速度快,插件丰富,有自己丰富的模板控制结构,模板标签,经过编译后速度快;
缺点:不适合中小型的项目,实时更新数据的网站不适合,第一次运行的时候,编译需要时间。
smarty下载:
1.www.smarty.net,下载smarty
2.配置域名:
1):httpd.cof Include conf/extra/httpd-vhosts.conf 去掉#
2): conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "c:/wwwroot"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName www.tk116smarty.com
DocumentRoot "C:/wwwroot/116middleclass/smarty/tk116smarty"
</VirtualHost>
3)host文件 C:\WINDOWS\system32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 www.tk116smarty.com
4)重启Apache服务器
3.复制libs目录,到smarty/tk116smarty/ 并更名为smarty
-SmartyBC.class.php smarty的向后兼容性的包装类 兼容2.x
-Smarty.class.php smarty的核心类解析文件
-Autoloader.php 自动加载smarty类文件
/plugins smarty的插件目录
/sysplugins smarry的核心插件目录
4.新建/tk116smarty/smarty.inc.php,smarty的初始化文件,引入smarty自定加载类文件
require("./smarty/Autoloader.php");
5.调用Smarty_Autoloader::register() 注册自动加载类函数
创建smarty对象:$smarty=new smarty();
6.运行环境的配置
$smarty->template_dir = "./template"; // 手动创建这个目录
$smarty->compile_dir = "./comp"; // 编译目录
$smarty->cache_dir = "./cache";
7.新建程序页面 /index.php 并引入smarty的初始化文件 require("./smarty.inc.php");
新建模板页面 /template/index.html
8.使用smarty对象调用模板方法
$smarty->display("模板文件名.后缀");
简单的讲,目的就是要使用php的程序员同美工分离,使程序员改变程序
的逻辑内容不会影响到美工的页面设计,美工重新修改页面不会影响到
程序员的逻辑,这样在多人合作的项目中尤其重要。
smarty
优点:速度快,插件丰富,有自己丰富的模板控制结构,模板标签,经过编译后速度快;
缺点:不适合中小型的项目,实时更新数据的网站不适合,第一次运行的时候,编译需要时间。
smarty下载:
1.www.smarty.net,下载smarty
2.配置域名:
1):httpd.cof Include conf/extra/httpd-vhosts.conf 去掉#
2): conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "c:/wwwroot"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName www.tk116smarty.com
DocumentRoot "C:/wwwroot/116middleclass/smarty/tk116smarty"
</VirtualHost>
3)host文件 C:\WINDOWS\system32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 www.tk116smarty.com
4)重启Apache服务器
3.复制libs目录,到smarty/tk116smarty/ 并更名为smarty
-SmartyBC.class.php smarty的向后兼容性的包装类 兼容2.x
-Smarty.class.php smarty的核心类解析文件
-Autoloader.php 自动加载smarty类文件
/plugins smarty的插件目录
/sysplugins smarry的核心插件目录
4.新建/tk116smarty/smarty.inc.php,smarty的初始化文件,引入smarty自定加载类文件
require("./smarty/Autoloader.php");
5.调用Smarty_Autoloader::register() 注册自动加载类函数
创建smarty对象:$smarty=new smarty();
6.运行环境的配置
$smarty->template_dir = "./template"; // 手动创建这个目录
$smarty->compile_dir = "./comp"; // 编译目录
$smarty->cache_dir = "./cache";
7.新建程序页面 /index.php 并引入smarty的初始化文件 require("./smarty.inc.php");
新建模板页面 /template/index.html
8.使用smarty对象调用模板方法
$smarty->display("模板文件名.后缀");