PHP DOM Template

openkk 9年前
     PHP DOM Template 是一个快速的 PHP 模板引擎,下面是一个 Hello World 的例子:    <pre class="brush:php; toolbar: true; auto-links: false;"><?php // Start the output buffer ob_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""> <html xmlns=""> <head>   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   <title>PHP Dom Template (PDT) Library - example01.html</title>   <link rel="stylesheet" type="text/css" href="../css/stylesheet.css" /> </head> <body>   <p><a href="../example01.php">Back To Example 1</a></p>   <div id="content">     <h1>Hello World</h1>     <p var="helloWorld">Default Text</p>     <p>&#160;</p>     <p class="copyright"><a href="">Copyright 2008 PHP DOM Template</a></p>   </div>   <p><a href="../example01.php">Back To Example 1</a></p> </body> </html> <?php // include the Template lib include_once dirname(__FILE__) . '/../Template.php'; // Create a template from the html in the buffer $buff = ob_get_clean(); $template = Dk_Dom_Template::loadXml($buff); $template->replaceText('helloWorld', 'This is the `Hello World` Dynamic text.'); echo $template->getDocument()->saveXML(); ?></pre>    <p><strong>项目主页:</strong><a href="" target="_blank"></a></p>