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
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔