Simple Handmade PHP Template Engine not working! Help Please

sonofagun

New Member
These are the class definitions\[code\]<?php abstract class MyTemplate { protected $arrayOfSpaces; protected $arrayOfVariables; protected $output; protected abstract function __construct(); function outputHTML(){ echo $output; //Apparently, the problem is HERE. <<<<>>>>> }} class MyTemplateMain extends MyTemplate { function __construct(){ $this->output="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> </head> <body> I love Rock n Roll!!! </body> </html>"; } }?>\[/code\]And this is where I launch this page\[code\]<?php require_once("view/templates.php"); $page=new MyTemplateMain(); $page->outputHTML();?>\[/code\]Doesn't work, though. Just shows a blank page, without the String I love rock n roll which was supposed to appear in the body.I'm sure there are better ways to implement templates but I just want to figure out why this particular example doesn't workAny help is appreciated. ThanksPS: The quotes are all duly escaped and the file paths are ok too
 
Back
Top