喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

[北京]代朋友公司招聘PHP高级程序员多名

上一主题 下一主题
     
标题: [代码] phplib使用问题。  
 
faby (faby)
新手上路
Rank: 1
初级会员



UID 63968
精华 0
积分 32
帖子 28
金钱 32 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2005-4-3
状态 离线
phplib使用问题。

Use Template direcly or define a subclass of Template as needed.

Define a template file named page.ihtml as follows:



--------------------------------------------------------------------------------

<html>
<head><title>{PAGETITLE}</title></head>
<body bgcolor="#ffffff">
<table border=1 cellpadding=4 cellspacing=0 bgcolor="#eeeeee">
  <tr>
   <td colspan=2><h1>{PAGETITLE}</h1></td>
  </tr>
  <tr>
   <td>{OUT}</td>
   <td>Content</td>
  </tr>
</table>
</body>
</html>


--------------------------------------------------------------------------------


This file contains a reference to the variable pagetitle and a reference to the variable named out. Another template file, named box.ihtml, contains a block named row with three variable references {TITLE}, {NUM} and {BIGNUM}:



--------------------------------------------------------------------------------

<!-- start box.ihtml -->
<table border=1 bgcolor="#cccccc" cellpadding=4 cellspacing=0>
<tr>
  <td colspan=2><b>{TITLE}</b></td>
</tr>
  <!-- BEGIN row -->
  <tr>
   <td>{NUM}</td>
   <td>{BIGNUM}
  </tr>
  <!-- END row -->
</table>
<!-- end box.ihtml -->


--------------------------------------------------------------------------------


The following php3 file demonstrates how to use these templates:



--------------------------------------------------------------------------------

<?php
  
include("./template.inc");

  
# create Template instance called $t  
  
$t = new Template("/page/to/webserver/template""keep");

  
# define variables named page and box, referencing files
  
$t->set_file(array(
     
"page" => "page.ihtml",
     
"box"  => "box.ihtml"));

  
# extract the block named "row" from "box", creating a
  # reference to {rows} in "box".
  
$t->set_block("box""row""rows");

  
# define the variables TITLE and PAGETITLE
  
$t->set_var(array("TITLE"     => "Testpage",
                    
"PAGETITLE" => "hugo"));

  
# define NUM and BIGNUM, then append "row" to "rows"...
  
for ($i=1$i<=3$i++) {
    
$n  $i;
    
$nn $i*10;
    
$t->set_var(array("NUM" => $n"BIGNUM" => $nn));
    
$t->parse("rows""row"true);
  }

  
# build out from box, then build out from page...
  
$t->parse("OUT", array("box""page"));

  
# finish out and print it.
  
$t->p("OUT");
?>
<hr>
<?php
  
# report leftover variables, if any.
  
print implode(", "$t->get_undefined("rows"));
 
?>
上面的两行代码看不明白:

<?php
$t
->set_var(array("TITLE"     => "Testpage",
                    
"PAGETITLE" => "hugo"));
?>


<?php
$t
->parse("OUT", array("box""page"));

  
# finish out and print it.
  
$t->p("OUT");
?>
如果我想写三个文件,那么应该怎么设置
$->parse函数?
谢谢大家!
2007-6-12 05:16 PM#1
查看资料  发短消息  顶部
 
robin830421
注册会员
Rank: 2


UID 74419
精华 0
积分 125
帖子 100
金钱 125 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2006-6-1
状态 离线
[推荐阅读] PHP Cheat Sheet
孩子 加油



PHP同盟会
php群  28064637
2007-6-12 10:36 PM#2
查看资料  发短消息  顶部
 
jtql420 (披着羊皮的狼)
金牌会员
Rank: 6Rank: 6
披着羊皮的狼


UID 70611
精华 0
积分 1965
帖子 444
金钱 1965 喜悦币
威望 0
人脉 0
阅读权限 70
注册 2006-3-29
来自 深圳
状态 离线
[推荐阅读] 初次接触php,应该从哪开始学?


<?php
$t->set_var(array("TITLE"     => "Testpage",
                    "PAGETITLE" => "hugo"));
?>
相当于
<?php
$t->set_var(("TITLE","Testpage");

$t->set_var("PAGETITLE" ,"hugo");

?>
另一个不知道是什么意思,




披着羊皮的狼 http://jtql420.cn
2007-6-13 01:58 PM#3
查看资料  访问主页  发短消息  QQ  顶部
 
jtql420 (披着羊皮的狼)
金牌会员
Rank: 6Rank: 6
披着羊皮的狼


UID 70611
精华 0
积分 1965
帖子 444
金钱 1965 喜悦币
威望 0
人脉 0
阅读权限 70
注册 2006-3-29
来自 深圳
状态 离线
[推荐阅读] 如何在linux下工作?
关于set_block刚找到一个好点的实例贴上来了。

http://www.phpe.net/articles/333.shtml




披着羊皮的狼 http://jtql420.cn
2007-6-13 02:35 PM#4
查看资料  访问主页  发短消息  QQ  顶部
 
Maxwin
注册会员
Rank: 2



UID 88106
精华 0
积分 116
帖子 99
金钱 116 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2007-2-6
状态 离线
[推荐阅读] 村长 来一下
我先前写的一点 ,看看有没有帮助  http://www.x2blog.cn/maxwin/?tid=7311



Blog:http://www.x2blog.cn/Maxwin/
2007-6-13 03:39 PM#5
查看资料  访问主页  发短消息  QQ  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.026484 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP