</TABLE>
table_row.tpl
以下为引用的内容:
<TR>
<TD>{FILENAME}</TD>
<TD>{FILESIZE}</TD>
</TR>
yad.php3
以下为引用的内容:
<?php
include "class.FastTemplate.php3";
function InitializeTemplates() {
global $tpl;
$tpl = new FastTemplate( ".");
$tpl->define( array( page => "page.tpl",
table => "table.tpl",
table_row => "table_row.tpl" ) );
}
function ReadCurrentDirectory() {
global $tpl;
$handle = opendir( ".");
while($filename = readdir($handle)) {
$tpl->assign(FILENAME, $filename);
$tpl->assign(FILESIZE, filesize($filename));
$tpl->parse(TABLE_ROWS, ".table_row");
}
closedir($handle);
$tpl->parse(PAGE_CONTENT, "table");
}
function PrintPage($title) {
global $tpl;
$tpl->assign(PAGE_TITLE, $title);
$tpl->parse(FINAL, "page");
$tpl->FastPrint(FINAL);
}
InitializeTemplates();
ReadCurrentDirectory();
Printpage( "Yet Another Demo");
?>
速度讨论
"Ok," 你可能会说,"一切都太好了。但是它不会影响我的网站的速度吗?" www~
不,你的网站可能变得更快。一个简单的原因就是:因为你作为一个编程人员关心的是设计你的应用和编写代码,你的代码将会更有效率,处理相同的任务更容易和更快速。所以,你可能会在上面列出的为什么考虑使用FastTemplate在你的项目中的原因列表中增加另一条理由。
如果你只是想转换一个已经存在的web站点,性能上的成功可能不会被注意到。我建议在PHP中使用正则表达式缓冲,它将对这种情况有所帮助。因为FastTemplate对每一个宏都使用正则表达式,每一个正则表达式将被只编译一次并且速度上的影响可以忽略不计。







