b.php
<?php
include("../init.inc.php");
$title="smarty学习";
$content="smarty模板的介绍";
//分配变量
$tpl->assign("title",$title);
$tpl->assign("content",$content);
//调用模板文件
//./tpl/a.html
$tpl->display("./tpl1/a.tpl");
?>
a.tpl
<html>
<head>
<title> <{$title}> </title>
<link rel="stylesheet" href="../css/*.css">
</head>
<body>
<img src="../tpl/tpl1/1.jpg" >
<i> <{$content}> </i>
</body>
</html>
init.inc.php
<?php
require ("../libs/Smarty.class.php");
define('ROOT','D:/wamp/www/smartyMB/smarty/');
//创建模板对象
$tpl = new Smarty();
$tpl->template_dir = ROOT.'tpl';
$tpl->compile_dir = ROOT.'tpl_c';
$tpl->left_delimiter = '<{';
$tpl->right_delimiter ='}>';
?>
下载smarty模板