Tizag.com Webmaster Tutorials - A collection of webmaster tutorials from HTML to PHP.

Saturday, June 19, 2010

A Simple Class to Generate Dynamic PHP Pages

<?php
class GeneratePage {
var $title;
var $pageContent;

function Display( ) {
echo "<html>\n<head>\n";
$this->displayTitle();
echo "\n</head>\n<body>\n";
echo $this->pageContent;
echo "\n</body>\n</html>\n";
}

function displayTitle() {
echo "<title>" . $this->title . "</title>\n";
}

function SetContent($Data) {
$this->pageContent = $Data;
}
}


//call the class to generate the page


$newPage = new GeneratePage;
$mypageContent = "The quick brown fox jumps over the lazy dog.";
$newPage->title = "A Sample Page.";
$newPage->SetContent($mypageContent);
$newPage->Display();
?>

No comments: