Template engine disables PHP -


so build template engine, when parse files, disables php, make me unable sitename , stuff. parser (rlly lightweight)

class template {      public  function __construct($directory) {         $this->directory = $directory;     } public function gettemplate($filename) {     $file = "app/themes/" . $this->directory . "/" . $filename . ".php";     if(!file_exists($file)) {         die("het opgevraagde bestand bestaat niet.");     } else {         $this->content = file_get_contents($file);         echo $this->content;     } } 

}

does know way enable php again? way, i'm running on template:

$core->getsitename

please note isn't existing template engine.

simply include page (instead of loading via file() etc.). if so, output buffer comes in handy well:

public function gettemplate($filename) {     $file = "app/themes/" . $this->directory . "/" . $filename . ".php";     if(!file_exists($file)) {         die("het opgevraagde bestand bestaat niet.");         //better throw error instead     } else {         ob_start();         include $file;         $this->content = ob_get_contents();         ob_end_clean();     } } 

there alot of (good) template engines available php. instead of reinventing them, i'd suggest using 1 of them. however, if still want develop own, sources , find out how solved problems face. lot of thought , sweat went solutions.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -