教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 在php中配置使用smarty模板引擎

在php中配置使用smarty模板引擎

发布时间:2016-10-29   编辑:jiaochengji.com
教程集为您提供在php中配置使用smarty模板引擎等资源,欢迎您收藏本站,我们将为您提供最新的在php中配置使用smarty模板引擎资源

Smarty是php的半官方模板引擎,从其主页位置就可以看出。使用简单,功能强大,本文就介绍一下smarty模板的安装和使用。

1) 现在模板的安装包,解压到根目录外的某个位置,比如解压到c:phpLibsmarty

2)修改 php.ini文件,配置include_path。 如此文中的配置为:include_path="c:phpLibsmartylibs"

     注意,要把include_path前的分号去掉

3) 创建存放模板文件和配置文件的四个目录

       templates 存放模板文件的目录

      template_c 防止smarty编译的模板文件

      configs 放置专用的配置文件目录

       cache   在启用缓存的情况下,放置smarty缓存的所有文件

4)在php脚本使用smarty模板前,先制定上述四个目录的位置:

<?php

$smarty = new Smarty;
$smarty->template_dir = "templates";
$smarty->compile_dir = "template_c";
$smarty->config_dir = "configs";
$smarty->cache_dir = "cache";

?>

 

完成上述四个步骤后,就可以使用smarty模板了

 



您可能感兴趣的文章:
在php中配置使用smarty模板引擎
smarty获得当前url示例代码
smarty模板中get、post、request、cookies、session变量用法
PHP模板引擎Smarty缓存使用
有关smarty模板引擎生成静态页的关键代码
PHP模板引擎smarty生成随机数 smarty中math函数用法
php smarty 基础
有关smarty的基本设置
php模版生成html的小例子
php smarty模板引擎实用技巧

[关闭]
~ ~