最新下载
热门教程
- 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)
相关文章
- 币圈平台哪个好?各大平台储备金查看 07-04
- 炉石传说5月30日狂野模式强力卡组推荐 07-04
- 坦克世界索玛S35配件选择指南 07-04
- 无畏契约实圆准星代码分享 07-04
- Bitget怎么注册?Bitget交易所注册下载及交易认证教程 07-04
- 艾尔登法环黑夜君临发育路线规划推荐 07-04