刚接触模版,请大家帮忙!
从Phpe.net上得到的一段代码,运行后出现错误!
Fatal error: Cannot redeclare clear_parse() in D:\WEBSITE\Template\class.FastTemplate.php on line 666
(文件我也是从phpe上得来的,我想应该不会有问题吧!)
代码如下:
<!-- main.htm -->
<html>
<head><title>模板示例</title></head>
<body>
<table><tr><td>{HEADER}</td></tr>
<tr><td>{LEFTNAV}</td><td>{CONTENT}</td></tr>
</table>
</body></html>
<!-- header.htm -->
<img src="sitelogo.jpg">
<!-- leftnav.htm -->
<br><a href="foo">Foo</a>
<br><a href="bar">Bar</a>
// example.php
<?php
require('class.FastTemplate.php');
$tpl = new FastTemplate('.');
$tpl->define( array( 'main' => 'main.htm',
'header' => 'header.htm',
'leftnav' => 'leftnav.htm' ) );
// 此处的PHP代码设置$content使其包含合适的页面内容
$tpl->assign('CONTENT', $content);
$tpl->parse('HEADER', 'header');
$tpl->parse('LEFTNAV', 'leftnav');
$tpl->parse('MAIN', 'main');
$tpl->FastPrint('MAIN');
?>