index.php
<?
include (\"parser.php\");
$tpl = new template;
$tpl -> load(index.tpl);
\"TYTOL\" => \"Moja pierwsza strona z szablonami\",
\"MENU\" => \"DUPA\",
\"TRESC\" => \"hohohoho dziala:)\"
);
$tpl->parse();
?>
index.tpl
<?php
<html>
<head>
<TITLE>{TYTOL}</TITLE>
</head>
<body>
<table>
<tr><td>{MENU}</td><td>{TRESC}</td></tr>
<table>
</body>
</html>
?>
parser.php
<?
class template
{
var $unparsed = array(0 => ''); var $parsed = '';
var $blocks = array('default' => '');
function load($plik)
{
$this -> unparsed
= @file($plik); }
function parse()
{
$this -> parsed = \"\";
$cnt = count($this -> unparsed
); for($i = 0; $i <= $cnt; $i++)
{
$tekst = $this -> unparsed[$i];
{
foreach($found[1] as $block)
{
$block_names[] = '{'.$block.'}';
$block_values[] = &$this -> blocks[$block];
}
$tekst = str_replace($block_names, $block_values, $tekst); }
$this -> parsed .= $tekst;
}
}
}
?>
Moja glupota... juz dziala ;/
Ten post edytował ActivePlayer 6.07.2004, 22:59:00