smarty_inc.php配置页面
<?php
include_once("smarty/Smarty.class.php");//包含smarty类文件
$smarty=new Smarty();//建立smarty实例对象
$smarty->config_dir="smarty/Config_File.class.php";//目录变量
$smarty->caching=false;//是否使用缓存
$smarty->template_dir="./templates";//设置模板目录
$smarty->compile_dir="./templates_c";//设置编译目录
$smarty->cache_dir="./smarty_cache";//缓存文件
$smarty->left_delimiter="{";
$smarty->right_delimiter="}";
?>
index.php页面
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<?php
include("smarty_inc.php");
$name="php";
$smarty->assign("title",$name);
$smarty->display("index.html");
?>
在templates文件中index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><b>{$title}</b></title>
</head>
<body>
<b >{$title}</b>
</body>
</html>
转载于:https://blog.51cto.com/xiaochaozi/1204998