php模板技术 实例
1. 站点结构
?
?
站点
┗includes
? ?┗class.inc
┣templates
? ?┗index.htm
? ?┣list.htm
? ?┗content.htm
┣index.php
┗content.php
?
2.库结构
?
?
?
?
------------------list.htm文件-------------------
?
?
?
?
?
-------------------content.htm文件-----------------------
?
?
?
?
----------------index.php文件--------------------------
?
?
<?php include('includes/class.inc'); $tmpl = new template(); $db = new db(); $con = $db->connect(); mysql_select_db('test',$con); $tmpl->get_file('templates/content.htm'); $rs = mysql_query('select * from test where id='.$_GET['id']); $row=@mysql_fetch_row($rs); unset($row[0]); //去掉表中读出的多余字段,对齐替换项,或在SELECT语句中列表字段$tags = array('name','sex','age','email','back'); $row[] = '<a href="index.php">Back</a>';echo $tmpl->parse($tags,$row); ?>?
?
?
finished
?
?
?