im trying to make a simple template engine but am having a problem replacing the string in the content....if anyone could give me any help or pointers please
<?php
class Template
{
public function display($filename)
{
echo "hello";
}
public function assign($variable, $value)
{
if (!is_array($value))
{
ob_start();
$contents = ob_get_contents();
$contents = str_replace($variable, $value, $contents);
ob_end_clean();
return $contents;
}
}
}
$template = new Template();
$template->display();
$template->assign("hello", "test");
?>
code above will only display hello and not test as it should