通用部分分离为一个单独的文件,当然可以了 但怎么是“把一个模板文件的内容付给另外一个模板文件中的某个变量”呢?$page = new SmartTemplate(模板1); //相关处理 $page->output();$page = new SmartTemplate(模板2); //相关处理 $page->output();$page = new SmartTemplate(模板3); //相关处理 $page->output(); ....我通常写成独立的程序,然后在主程序里嵌入 include "模板程序1.php"; include "模板程序2.php"; include "模板程序3.php"; ...不是很简单吗?
但怎么是“把一个模板文件的内容付给另外一个模板文件中的某个变量”呢?$page = new SmartTemplate(模板1);
//相关处理
$page->output();$page = new SmartTemplate(模板2);
//相关处理
$page->output();$page = new SmartTemplate(模板3);
//相关处理
$page->output();
....我通常写成独立的程序,然后在主程序里嵌入
include "模板程序1.php";
include "模板程序2.php";
include "模板程序3.php";
...不是很简单吗?
$page2 = new SmartTemplate(模板2);
$page1->assign("COMMON", $page2->result());
$page1->output();