I have just started to use classes and I can't recognize what is wrong with that code. It's purpose is to read templates and print them. Well this is my code:
<?php
class template_raam{
var $templeidi_nimi;
var $lehe_sisu;
var $pealkiri;
var $raamitud;
function loe_temp($path, $filename)
{
$source = join("",file($path ."/". $filename));
if (strlen($source) == 0)
{
die("Templatefaili ei õnnestud avada!");
};
return $source;
}
function asenda_temp($source, $vars)
{
if (is_array($vars))
{
foreach($vars as $key => $value)
{
$tag = "{VAR:" . $key . "}";
$source = str_replace($tag,$value,$source);
};
};
return $source;
$this->raamitud = $source;
}
function valjasta()
{
print $this->raamitud;
}
}
$dir = ".";
if($leht == "")
{
$templeit1 = new template_raam;
$templeit1->templeidi_nimi = "esileht.tpl";
$templeit1->lehe_sisu = "See ongi esileht";
$templeit1->pealkiri = "LayUp :: esileht";
$templeit1->loe_temp($dir, $templeit1->templeidi_nimi);
$templeit1->asenda_temp($templeit1->templeidi_nimi, array("pea_sisu" => $templeit1->lehe_sisu, "pealkiri" => $templeit1->pealkiri));
$templeit1->valjasta();
}
?>