PHP中FastTemplate制作静态网站的模板框架实例


模板1:main.htm

<html>
<head><title>模板示例</title></head>
<body>

  头部:{HEADER} <br /><br />

  栏目:{LEFTNAV} <br /><br />

  内容:{CONTENT}

  </body></html>

  模板2:header.htm

  <a href="http://www.trybb.com"><img src="http://www.trybb.com/images/logo.gif"></a>

  模板3:leftnav.htm

  <a href="http://www.trybb.com/free">免费试用</a>   <a href="http://sheng.trybb.com/">购物返利</a>

  PHP代码:test.php

<?php
require('class.FastTemplate.php');
$tpl = new FastTemplate('template');
$tpl->define( array( 'main' => 'main.htm','header' => 'header.htm','leftnav' => 'leftnav.htm' ) );
// 此处的PHP代码设置$content使其包含合适的页面内容
$content='猪子胖胖';
$tpl->assign('CONTENT', $content);
$tpl->parse('HEADER', 'header');
$tpl->parse('LEFTNAV', 'leftnav');
$tpl->parse('MAIN', 'main');
$tpl->FastPrint('MAIN');
?>


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3