Basit Tema Sistemi

<?php
class template
{
	private $file		= NULL;		// -- Load File
	private $content	= NULL;		// -- File Loaded
	private $tags		= array();	// -- Tags Added
	private $count		= 0;		// -- Loop of Tags
	public function fread($archive)
	{
		$this->file = @fopen($archive, "r");
		$this->content = @fread($this->file, filesize($archive));
		if(!$this->file) exit("Error open: {$archive}");
		if(!$this->content) exit("Error read: {$archive}");
	}
	public function set($name, $value)
	{
		$this->tags[$this->count++] = array("name" => $name, "value" => $value);
	}
	public function show()
	{
		foreach($this->tags as $tags)
			$this->content = str_replace("{".$tags['name']."}", $tags['value'], $this->content);
			
		eval("?>".$this->content."<?");
	}
}
define("TITLE", "Ben Sayfa Başlığıyım"); // -- Page Title
$veri="ben bir sayfa içeriğiyim";


$template = new template(); // -- Load Class

$template->set("TITLE", TITLE); // -- Add the tag {TITLE}
$template->set("ICERIK", $veri); // -- Add the tag {ICERIK}

switch($_GET["page"])
{
	case "home" :
	$template->fread("template/index.tpl.php"); // -- Load the index.tpl.php
	break;
	default : 
	$template->fread("template/index.tpl.php"); // -- Load the index.tpl.php
	break;
}

$template->show(); // -- Show template

//alttaki html kodlarını template/index.tpl.php dosyası oluşturarak içine yazınız
/*
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{TITLE}</title>
</head>

<body>
{CONTENT}
</body>
</html>
*/
// çalıştırmak için  localhost/index.php?page=home tarzı case e göre
?>