phplib的嵌套block问题
Arbow 2002-07-25 08:37:32 phplib具有block功能,可以把一部分代码重复显示。请问能否进行block的嵌套?
模板:1.tpl:
<table border="1">
<!-- BEGIN row -->
<tr>
<!-- BEGIN col -->
<td>{NUM}</td>
<!-- END col -->
</tr>
<!-- END row -->
</table>
php程序代码:
<?
include("./include/template.inc");
$t =new Template(".");
$t->set_file ("fHandle","1.tpl");
$t->set_block ("fHandle","row","rows");
for ($i=1;$i<5;$i++)
{
$t->set_block ("fHandle","col","cols");
for ($j=1;$j<5;$j++)
{
$num=$i*$j;
$code=$i.'*'.$j.'='.$num;
$t->set_var ("NUM","$code");
$t->parse ("cols","row",true);
}
$t->parse ("rows","row",true);
}
$t->parse ("out","fHandle");
$t->p("out");
?>
结果程序输出:
<table border="1">
<tr>
<!-- BEGIN col -->
<td>1*4=4</td>
<!-- END col -->
</tr>
<tr>
<!-- BEGIN col -->
<td>2*4=8</td>
<!-- END col -->
</tr>
<tr>
<!-- BEGIN col -->
<td>3*4=12</td>
<!-- END col -->
</tr>
<tr>
<!-- BEGIN col -->
<td>4*4=16</td>
<!-- END col -->
</tr>
</table>
的页面,可见里层的block没有被执行。
对此请问php高手们phplib能否进行嵌套block?如果,可以,麻烦给出修改后的程序,谢谢~~50分等着你:)