<html>
.....
<body>
...
...
</body>
</html>
test.php
<?php
$mydate=date("Y年m月d日"); //處理好變量的值
include("template.inc"); //調入將模板程序模塊
$mytemp = new Template("/你的模板檔案所在目錄/");
//創建一個模板實例mytemp,如果模板就在當前目錄,那麼使用"."就可以
$mytemp->set_file("MyFileHandle","MyTemplate.html");
//設置MyFileHandle檔案句柄指向我們所要調用的模板檔案Mytemplate.html
$mytemp->set_var("today"、mydate);
//調用模板的set_var方法,設置模板中的變量today值為$mydate
$mytemp->parse("MyOutput","MyFileHandle");
//調用模板的parse方法,對MyFileHandle檔案句柄所指向的模板檔案進行分析,替換其中相應變
量
//並把替換結果即完整的HTML檔案內容保存在字串變量MyOutput中
$mytemp->p("MyOutput");
// 列印輸出結果字串變量MyOutput的值
?>