Parse error: syntax error, unexpected $end in /home/vxlabs/public_html/test/template.engine.php(56) : eval()'d code on line 11
heres my template.engine.php code
<?php
class TemplateEngine // This is our TemplateEngine class.
{
var $Template; // Current Templates Name.
var $TemplateExt = '.tpl'; // Templates File ext.
var $TemplateDir = './templates/'; // Templates Dir.
function SelectTemplateFile($file, $error_line = 0, $error_file = '') // This function will select the requested templates .tpl file.
{
if(is_dir($this->TemplateDir)) // If the $templatedir exsits.
{
if(!file_exists($this->TemplateDir.$file.$this->TemplateExt)) // If the .tpl file does not exsit.
{
$error = "<b>File:</b> ".$error_file."<br/>
<b>Line:</b> ".$error_line."<br/>
<b>Date:</b> ".date("D M j G:i Y")."<br/><br/>
Error loading ".$this->TemplateDir.$file.$this->TemplateExt.", file does not exist.";
return die($error); // Returns $error.";
}
elseif(file_exists($this->TemplateDir.$file.$this->TemplateExt)) // ElseIf the file exsits.
{
return $this->Template=file_get_contents($this->TemplateDir.$file.$this->TemplateExt); // Returns the current templates data.
} // End ElseIf.
}
elseif(!is_dir($this->TemplateDir)) // ElseIf the directory does not exsit.
{
$error = "<b>File:</b> ".$error_file."<br/>
<b>Line:</b> ".$error_line."<br/>
<b>Date:</b> ".date("D M j G:i Y")."<br/><br/>
Error opening ".$this->TemplateDir.", directory does not exist.";
return die($error); // Returns $error.
} // End ElseIf.
} // End Function.
function ReplaceVars($vars=array(), $error_line = 0, $error_file = '') // This will replace {var} with a array value.
{
if (sizeof($vars) > 0) // If the array of vars is not emtpy.
{
foreach ($vars as $var => $content) // Loops through the array.
{
$this->Template=str_replace("{".$var."}", $content, $this->Template); // Replaces {var} with the array value ($content).
} // End Foreach.
}
else // Else the array of vars is empty.
{
$error = "<b>File:</b> ".$error_file."<br/>
<b>Line:</b> ".$error_line."<br/>
<b>Date:</b> ".date("D M j G:i Y")."<br/><br/>
Error no tags destined for replacemnt.";
return die($error); // Returns $error.
} // End Else.
} // End Function.
function Compile() // This function will compile to template and display it.
{
eval("?>".$this->Template."<?php"); // This simply allows us to add php into the .tpl file it self, and also returns the finished template.
} // End Function.
} // End Class
?>
