I’m redesigning a site using mostely classes, and I’m still trying to learn how to go about doing it. Right now I’m just working on getting a basic HTML structure working. Most of the sites that I’ve seen explaining ways to do it (all 3 of them), say to structure it like this:
[code=php]
class Page {
var $Title;
var $Keywords;
var $Content;
function Display( ) {
echo “<HTML>n<HEAD>n”;
$this->DisplayTitle( );
$this->DisplayKeywords( );
echo “n</HEAD>n<BODY>n”;
echo $this->Content;
echo “n</BODY>n</HTML>n”;
}
function DisplayTitle( ) {
echo “<TITLE>” . $this->Title . “</TITLE>n”;
}
function DisplayKeywords( ) {
echo ‘<META NAME=”keywords” CONTENT=”‘ . $this->Keywords . ‘”>’;
}
function SetContent( $Data ) {
$this->Content = $Data;
}
}
And I understand that way of doing it. However, I’m wanting to do something else because having the SetContent() function in there, basically just call up the beginning of the html, do the content on the page, and then call up the end of the html. Kinda like this:
[code=php]class HTML {
var $title, $keywords, $description;
var $docType = ‘<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>’;
var $jsBasic = ‘<script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js”></script>’;
public function BeginHTML() {
$str = $this->docType.’
<html lang=”en” xmlns=”http://www.w3.org/1999/html”>
<head>
<title>’.$this->title.'</title>
<meta name=”robots” content=”INDEX, FOLLOW” />
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<meta name=”keywords” content=”‘.$this->keywords.'” />
<meta name=”description” content=”‘.$this->description.'” />
<link href=”main-style.css” rel=”stylesheet” type=”text/css” />
‘.$this->jsBasic;
$str .= ‘ </head>
<body>
<div class=”fbv_Bodywrap”>’;
}
public function EndHTML() {
$str = ‘
</div>
</body>
</html>’;
}
}
When I try to call each of the functions on my page, I’m able to get the Begin, but not the End. Anyone got some suggestions for me?