最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
smarty 安装与配置教程
时间:2022-07-02 10:47:14 编辑:袖梨 来源:一聚教程网
smarty 安装与配置
1.在www.smarty.net 下载smarty,解压 。假设解压目录为Smarty-2.6.19。
2.在网站主目录下建立文件夹smartytest(比如:XAMPP下 E:xampphtdocssmartytest) 同时在 smartytest目录下建立如下几个目录:cache ,configs ,templates, templates_c。并且将Smarty-2.6.19下libs目录全部复制到smartytest目录下。
3.将以下代码保存到config.php中 并将文件保存到 smartytest下(smartytest/config.php)
php
include "libs/Smarty.class.php";
@define('__SITE_ROOT', str_replace("[url=file://]","/",dirname(__FILE[/url]__)));
$tpl = new Smarty();
$tpl->template_dir = __SITE_ROOT . "/templates/";
$tpl->compile_dir = __SITE_ROOT . "/templates_c/";
$tpl->config_dir = __SITE_ROOT . "/configs/";
$tpl->cache_dir = __SITE_ROOT . "/cache/";
$tpl->left_delimiter = '<{';
$tpl->right_delimiter = '}>';
?>
4. 修改php.ini中(我的是XAMPP 修改的是php/php5.ini和apache/bin/php.ini)
; Windows: "path1;path2"
include_path = ".;E:xamppphppear;E:/xampp/htdocs/smartytest/libs" (指向smartytest 中的libs 绝对路径).
改后 重启apache.
5.测试:将以下代码保存到 test.php 中 smartytest/test.php
php
require "config.php";
$tpl->assign("title", "测试成功了,这是标题");
$tpl->assign("content", "这是内容");
$tpl->display('test.html');
?>
将以下代码保存 test.html中 smartytest/templates/test.html
<{$content}>
6.运行test.php 文件(XAMPP下 http://localhost/smartytest/test.php)
相关文章
- 《弓箭传说2》新手玩法介绍 01-16
- 《地下城与勇士:起源》断桥烟雨多买多送活动内容一览 01-16
- 《差不多高手》醉拳龙技能特点分享 01-16
- 《鬼谷八荒》毕方尾羽解除限制道具推荐 01-16
- 《地下城与勇士:起源》阿拉德首次迎新春活动内容一览 01-16
- 《差不多高手》情圣技能特点分享 01-16