TesoMayn
Boredom, it vexes me.
Okay so first we need the class file.
Save that as template.class.php
And now the file people access
To add more variables just add
Now for the template itself.
Save that as template.html or whatever you want, just be sure to name it in the load();
That is all, leave feedback
PHP:
<?
class iTemplate {
public $template;
function load($filepath) {
$this->template = file_get_contents($filepath);
}
function replace($var, $content) {
$this->template = str_replace("[$var]", $content, $this->template);
}
function publish() {
eval("?>".$this->template."<?");
}
}
?>
And now the file people access
PHP:
<?php
include "template.class.php";
$template = new iTemplate;
$template->load("template.html"); //change the the name of the template page
$template->replace("title", "iTes0 Template System"); //change to what you want the title to be
$template->replace("site", "DevBest"); //this is just an example you can change both values
$template->replace("by", "iTes0"); //as is this
$template->publish();
?>
To add more variables just add
PHP:
$template->replace("VARIABLE", "REPLACEMENT");
Now for the template itself.
HTML:
<html>
<head>
<title>[title]</title>
</head>
<body>
<h3>Hello there [site] members!</h3>
<p>This is a simple PHP template tutorial</p>
<p>This was created by [by]</p>
</body>
</html>
Save that as template.html or whatever you want, just be sure to name it in the load();
That is all, leave feedback