最新下载
热门教程
- 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)
相关文章
- 英雄联盟手游加里奥出装攻略 lol手游正义巨像加里奥天赋符文推荐 08-06
- 明日方舟界园肉鸽待机缘有什么用 历钱通宝待机缘效果 08-06
- 大侠立志传被围攻的山贼事件流程攻略 08-06
- 燕云十六声缺口袋把戏团无伤怎么过 鬼神愁无伤逃课打法 08-06
- win11网络连接不见了怎么解决 08-06
- 《QQ》小世界删除推过方法 08-06