最近晚上都吃面(方便面)
累啊。心也累了。事情多。上班的事多。个人的事多。什么事都多。...
- 娱乐乐园,
set_file("myfilehandle", "test.htm"); $t->set_var("myname", $myname); $t->set_block("myfilehandle", "animalList", "a"); $t->set_block("animalList", "plantList", "p"); for ($i = 0;$i $t->set_var("p"); $t->set_var("a" name=description>
作者 tmyu 发布于 2003-09-01 分类:php基础编程
我看了一下,怎么没看到替换test.htm的过程?哪位老哥讲讲替换过程
<?php
include_once("template.inc");
$t = new template(".");
$myname = "小猪噜噜";
$animal = array("动物", "植物");
$plant = array(array("小猪", "小白", "小强"), array("玫瑰", "向日葵"));
$t->set_file("myfilehandle", "test.htm");
$t->set_var("myname", $myname);
$t->set_block("myfilehandle", "animalList", "a");
$t->set_block("animalList", "plantList", "p");
for ($i = 0;$i < count($animal);$i++) {
$t->set_var("p");
$t->set_var("animal", $animal[$i]);
for ($j = 0;$j < count($plant[$i]);$j++) {
$t->set_var("plant", $plant[$i][$j]);
$t->parse("p", "plantList", true);
}
$t->parse("a", "animalList", true);
}
$t->parse("out", "myfilehandle");
$t->p("out");
?>
逛论坛交流:模板问题
$t->set_file("myfilehandle", "test.htm");
这句话是设置文件句柄,
$t->parse("out", "myfilehandle");
解析句柄
$t->p("out");
输出句柄
晕,看的时候没看loadfile函数,谢了
3 条回复
回复