main.php文件如下
<?php
require ('./comm/smarty.class.php');
define ('_SITE_ROOT','E:/smarty');
$tp1=new smarty();
$tp1->template_dir=_SITE_ROOT.'/templates/';
$tp1->template_c=_SITE_ROOT.'/templates_c/';
$tp1->config_dir=_SITE_ROOT.'/configs/';
$tp1->cache_dir=_SITE_ROOT.'/cache/';
$tp1->left_delimiter='{';
$tp1->right_delimiter='}';
?>test.php文件如下
<?php
require ('main.php');
global $tp1;
$tp1->assign('title','测试用的网页');
$tp1->assign('content','测试用的网页内容');
$tp1->display('test1.html');
?>
test1.html如下显示
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
{$title}
<br/>
{$content}
</BODY>
</HTML>