PHP模板引擎 ShellPage
openkk
13年前
一个简单易用的类,可以让你的整个网站布局基于模板文件,修改模板就能改变整个站点。示例代码: <pre class="brush:php; toolbar: true; auto-links: false;"><?php class ShellPage { var $templatefile = "./template.html"; var $title = "ShellPage Title"; var $content = "<p>Page Content Here</p>"; function ShellPage(){ } function display_page() { $templatearray = file("$this->templatefile"); $template = join("",$templatearray); $template = str_replace("<!--title-->","$this->title",$template); $templatesplit = explode("<!--content-->", $template); $templatetop = $templatesplit[0]; $templatebot = $templatesplit[1]; print $templatetop; print $this->content; print $templatebot; } } ?></pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1322988897671" target="_blank">http://www.open-open.com/lib/view/home/1322988897671</a></p>