简单快速的php模板引擎
1.调用
<?php require 'view.php'; $view=new view(); //第一种设置输出参数的方法 $view->setAttr("title", "Variable example"); //第二种设置输出参数的方法 $view->array = array( '1' => "First array item", '2' => "Second array item", 'n' => "N-th array item", ); $view->j = 5; //输入页头、内容、页脚 $view->display("header.php")->display('index.php')->display('footer.php')->render();
2.theme/views/index.php
{comment} 这是注释 {/comment} {if $array} {foreach $array as $key => $value} {$key} => {$value}<br /> {/foreach} {else} {/*}这也是注释{*/} <p>Array is empty!</p> {/if} {$i = 1} {while $i < $j} 当前 no. {$i}<br /> {$i++} {/while}