1。new 的问题
$t=new Template("$dir","$w");
$dir我知道是模板路径
$w是什么dd啊?
答:应该是错误提示
--------------------------------
2.set_var
$t->set_var("name","name",true);
true 和false有什么差别
答:true是追加,false的话不追加
--------------------------------
$t->set_var("name");
可以清空name
$t->finish($t->get_var("name"));
有什么用了?
答:可以直接用$t->set_var("name");来清空
$t->finish($t->get_var("name"));是用来清理标签的。
------------------------------------------------
3.程序如下<?php
 #a.php
  include("template.php");
 $ar1=array("1","2","3","4","5","6");
 $ar2=array("a","b","c","d","e","f");
 $t=new Template(".");
 $t->set_file(array("b"=>"b.php","c"=>"c.php"));
 $t->set_var("title","蓝"); for ($i=0;$i<count($ar1);$i++)
 {
    $t->set_var("ar1",$ar1[$i],true);
    $t->parse("tt","b",true);
 }
 $t->p("tt");
?>
//------------------
<!--b.php--> 
{ar1}  <br>
{title} <br>
<br>
显示

蓝 12 
蓝 123 
蓝 1234 
蓝 12345 
蓝 123456 

//-------------------- 
怎么{ar1}
是重复的?我想每次显示1个数据
答:因为你的数据是追加,输入也是追加,这是不断追加的结果,你应该在不用追加的地方清空一下或是不追加
-------------------------------------
4.两个模板的关系
<?php
#a2.php
  include("template.php");
 $ar1=array("1","2","3","4","5","6");
 $ar2=array("a","b","c","d","e","f");
 $t=new Template(".");
 $t->set_file(array("b"=>"b.php","c"=>"c.php"));
 $t->set_var("title","蓝"); for ($i=0;$i<count($ar1);$i++)
 {
  $t->set_var("ar1",$ar1[$i],true);
   for ($i=0;$i<count($ar2);$i++)
   {
    $t->set_var("ar1",$ar2[$i],true);
    $t->parse("rr","c",true);
   }
   $t->parse("tt","b",true);
 }
 $t->p("tt");
 $t->p("rr");
?>
<!--c.php-->
{ar2}<br>
显示
1abcdef 
蓝 我想让两个模板相互嵌套
eg.
1
abcdef
2
abcdef
3
abcdef
答:像这种情况用块就可以解决了,没有必要用嵌套,如果要嵌,应该有这样一句,$t->parse("arg1","c");即把c.php放到b.php中的arg1处。
---------------------------------------