Im trying to make a simple template system in PHP. I'm new to PHP, so it's nothing serious. I have some problems though:
A regular include works:
$variable = "test";
include("templates/news.html");
But this won't:
This says $variable
is undefined:
$variable = "test";
getTemplate("news");
The Function:
function getTemplate($tpl) {
$file = "templates/$tpl.html";
if (file_exists($file))
return include($file);
return false;
}
news.html
<h1>php echo $variable</h1>
the function works and includes the page but it dont write out the variables
I include the function on top of all pages.
Thanks in advance!