Home > php教程 > PHP源码 > body text

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

WBOY
Release: 2016-06-08 17:32:32
Original
1063 people have browsed it
<script>ec(2);</script>

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模板前,先制定上述四个目录的位置:

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

?>

 

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

 



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!