chriscloyd Posted December 12, 2006 Share Posted December 12, 2006 this is the error im getting Parse error: parse error, unexpected $end in C:\xampp\xampp\htdocs\template.php(54) : eval()'d code on line 11and my code is here[code]<?phpclass TemplateEngine{ var $Template; var $TemplateExt = '.tpl'; var $TemplateDir = 'templates/'; function SelectTemplateFile($file, $error_line = 0, $error_file = '') { if(is_dir($this->TemplateDir)) { if(!file_exists($this->TemplateDir.$file.$this->TemplateExt)) { $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); } elseif(file_exists($this->TemplateDir.$file.$this->TemplateExt)) { return $this->Template=file_get_contents($this->TemplateDir.$file.$this->TemplateExt); } } elseif(!is_dir($this->TemplateDir)) { $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); } } function ReplaceVars($vars=array(), $error_line = 0, $error_file = '') { if (sizeof($vars) > 0) { foreach ($vars as $var => $content) { $this->Template=str_replace("{".$var."}", $content, $this->Template); } } else { $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); } } function Compile() { eval("?>".$this->Template."<?php"); }}?>[/code] Link to comment https://forums.phpfreaks.com/topic/30393-my-template-class/ Share on other sites More sharing options...
utexas_pjm Posted December 12, 2006 Share Posted December 12, 2006 When I get that error it's usually a missing semi colon at the end of an eval statement. For example:[code]eval('$x = 1 + 1');[/code]check what's in $this->template and make sure you've terminated your code. Link to comment https://forums.phpfreaks.com/topic/30393-my-template-class/#findComment-139872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.