Basic PHP Templating System for HTML
The class:
-
<?
-
class Template {
-
public $template;
-
function load($filepath) {
-
}
-
function replace($var, $content) {
-
}
-
function publish() {
-
}
-
}
-
?>
The template (layout.html):
-
<html>
-
<head>
-
<title>#title#</title>
-
</head>
-
<body>
-
<h3>Hello #name#!</h3>
-
<p>The time is: #datetime#</p>
-
<? echo "<p>Embedded PHP works too!</p>"; ?>
-
</body>
-
</html>
use example:
-
<?
-
include "template.class.php";
-
-
$template = new Template;
-
$template->load("design.html");
-
$template->replace("title", "My Template Class");
-
$template->replace("name", "William");
-
$template->publish();
-
?>