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>

InfoQ

交流

讨论:模板问题

作者 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");
?>



逛论坛交流模板问题

加入书签
digg+,
reddit+,
del.icio.us+,
dzone+

3 条回复

回复

http://bbs.phpres.com/showthread.php.. 发表人 Double_ycn 发表于 09月18日
$t->set_file("myfilehandle", "test.h.. 发表人 huix 发表于 09月18日
晕,看的时候没看loadfile函数,谢了 发表人 tmyu 发表于 09月18日
  1. 返回顶部

    Re: 模板问题

    2003年09月18日 发表人 Double_ycn

  2. 返回顶部

    Re: 模板问题

    2003年09月18日 发表人 huix

    $t->set_file("myfilehandle", "test.htm");
    这句话是设置文件句柄,
    $t->parse("out", "myfilehandle");
    解析句柄
    $t->p("out");
    输出句柄

  3. 返回顶部

    Re: 模板问题

    2003年09月18日 发表人 tmyu

    晕,看的时候没看loadfile函数,谢了




  4. 我有话要讲:(可以匿名发表, 发广告的有多远请滚多远!!!)

    昵称: 请输入验证码:


抢着回答

最近晚上都吃面(方便面)

累啊。心也累了。事情多。上班的事多。个人的事多。什么事都多。...

请问为什么所有的PHP页面输出的中文都是...

请问为什么所有的PHP页面输出的中文都是乱码,包括按钮上的文字,...

my desktop

my desktop

键值和索引是不是一回事?

键值和索引是不是一回事?有这方面的教程吗

Paypal使用过程?

如果是买程序,用PAYPAL网上支付后,是不是直接就可以下载了?

今天出去了噢。在挂机呢?

哈哈,今天天气不热,我就没有来送水了啊。现在送好了啊。 嘿嘿...

求救:为什么我的浏览器不能打开php3文件...

在打开本地的php3文件时,只看到源代码,不能正常显示.

问一下操作com方面的

adsi是com组件,他的GetObject在php中怎么用? 下面这个是a...

学习,参与,讨论...php爱好者请进

http://www.csdn.net/develop/article/20/20772.shtm 发言...

菜菜问题:(

这里的dir属性有什么用,是什么意思

[]