4,251
社区成员




<?php
include_once 'config.php';
$smarty->display('index.tpl');
?>
<?php
header('Content-Type:text/html;charset=gb2312');
/* 定义服务器的绝对路径 */
define('BASE_PATH',$_SERVER['DOCUMENT_ROOT']);
/* 定义Smarty目录的绝对路径 */
define('SMARTY_PATH','/Smarty/');
/* 加载Smarty类库文件 */
require BASE_PATH.SMARTY_PATH.'Smarty.class.php';
/* 实例化一个Smarty对象 */
$smarty = new Smarty;
/* 定义各个目录的路径 */
$smarty->template_dir = BASE_PATH.SMARTY_PATH.'templates/';
$smarty->compile_dir = BASE_PATH.SMARTY_PATH.'templates_c/';
$smarty->config_dir = BASE_PATH.SMARTY_PATH.'configs/';
$smarty->cache_dir = BASE_PATH.SMARTY_PATH.'cache/';
$smarty->left_delimiter = '{%';
$smarty->right_delimiter = '%}';
$smarty->caching = false;
$smarty->debugging = false;
?>
title = "调用配置文件"
bgcolor = "#000000"
border = "5"
type = "计算机类"
name = "PHP从入门到精通"
{% config_load file="04.conf" %}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% #title# %}</title>
</head>
<body bgcolor="{% #bgcolor# %}">
<table border="{% #border# %}">
<tr>
<td>{% $smarty.config.type %}</td>
<td>{% $smarty.config.name %}</td>
</tr>
</table>
</body>
</html>
include_once '../libs/Smarty.class.php';
$smarty=new Smarty();
$smarty->template_dir="../templates/";
$smarty->compile_dir="../templates_c/";
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
<{$error3|default:" "}>//这里的空格有了就错
但是看了你的代码 貌似模板没有执行,直接按原字符输出了吧!以上给你一个参考 ,不知道能不能帮你