hie there
i've been reading about classes and inheritance in php.
i copied the following codes that implements the use of classes and inheritance but could not work.No error is being displayed when view the out from the browser but a blank page only.
the codes are as follows:
here is the code for the class named page.inc
<?php
class Page
{
// class Page's attribute
var $content;
var $title="TLA Contsulting Pty Ltd";
var $keywords="TLA Constulting,Three Page Abbreviation,some of my best friends are search engines";
var $buttons=array("Home"=>"home.php",
"Contact"=>"contact.php",
"Services"=>"services.php",
"Site Map"=>"map.php");
// class page's Operation
function SetContent($newcontent)
{
$this->content=$newcontent;
}
function SetTitle($newtitle)
{
$this->title=$newtitle;
}
function SetKeywords($newkeywords)
{
$this->keywords=$newkeywords;
}
function SetButtons($newbuttons)
{
$this->buttons=$newbuttons;
}
function Display()
{
echo "<html>\n<head>\n";
$this->DisplayTitle();
$this->DisplayKeywords();
$this->DisplayStyles();
echo"</head>\n<body>\n";
$this->DisplayHeader();
$this->DisplayMenu($this->buttons);
echo $this->content;
$this->DisplayFooter();
echo "</body>\n</html>\n";
}
function DisplayTitle()
{
echo "<title>$this->title</title>";
}
function KeyWords()
{
echo "<META name=\"keywords\" content=\"$this->keywords\">";
}
function DisplayStyles()
{
?>
<style>
h1{color:white;font size:24pt;text-align:center;
font-family:arial,sans serif}
.menu{color:white;font-size:12pt;text-align:center;
font-family:ariel,sans serif;font-weight:bold}
td{background:black}
p{color:black;font-size:12pt;text-align:justify;
font-family:ariel,sans serif}
p.foot{color:white;font-size:9pt;text-align:center;
font-family:ariel,sans serif;font-weight:bold}
a:link,a:visited,a:active{color:white}
</style>
<?php
}
function DisplayHeader()
{
?>
<table width="100%" cellpadding="12" cellspacing="0" border="0">
<tr bgcolor="Black">
<td align="left"><img src="logo.gif"></td>
<td>
<h1>TLA Consulting Pty Ltd</h1>
</td>
<td align="right"><img src="logo.gif"></td>
</tr>
</table>
<?php
}
function DisplayMenu()
{
echo "<table width=\"100%\" bgcolor=white"
."cellpadding=4 cellspacing=4>\n";
echo"<tr>\n";
// Calculate Button size
$width=100/count($buttons);
while (list($name,$url)=each($buttons))
{
$this->DisplayButton($width,$name,$url,!$this-IsURLCurrentPage($url));
}
echo "</tr>\n";
echo "</table>\n";
}
function IsURLCurrent($url)
{
if (strpos($GLOBALS["SCRIPT_NAME"],$url)==false)
{
return false;
}
else
{
return true;
}
}
function DisplayButton($width,$name,$url,$active=true)
{
if($active)
{echo"<td width=\"$width%\">
<a href =\"$url\">
<img src =\"s-logo.gif\" alt=\"$name\" border=0></a>
<a href=\"$url\"><span class menu >$name</span></a></td>";
}
else
{
echo "<td width=\"$width\">
<img src =\"side-logo.gif\">
<span class menu>$name</span></td>";
}
}
function DisplayFooter()
{
?>
<table width="100%" bgcolor="Black" cellpadding="12" border="0">
<tr>
<td>
<p class="foot">©TLA Consulting Pty Ltd.</p>
<p class="foot">Please See<a href="">Our Legal Information Page</a> </p>
</td>
</tr>
</table>
<?php
}
}
?>
then for the home page save as home.php the code is as follows:
<?php
require("page.inc") ;
$homepage=new Page();
$homepage->SetContent("<p>Welcome to the home os Consulting.
Please take some time to get to know us .</p>
<p>We specialize in serving your bussines needs and hope to hear from you soon.</p>");
$homepage->Display();
?>
then for the class named ServicesPage.php the codes are:
<?php
require("page.inc");
class ServicesPage extends Page
{
var $row2buttons=array("Re-engineering"=>"reengineering.php",
"Standard Compliance"=>"standards.php",
"Buzzword Compliance"=>"buzzword.php",
"Mission Statements"=>"mission.php");
function Display()
{
echo "<html>\n<head>\n";
$this->DisplayTitle();
$this->DisplayKeywords();
$this->DisplayStyles();
echo "</head>\n<body>\n";
$this->DisplayHeader();
$this->DisplayMenu($this->buttons);
$this->DisplayMenu($this->$row2buttons);
echo $this->content;
$this-DisplayFooter();
echo "</body>\n</html>\n";
}
}
$services=new ServicesPage();
$content="<p>At TLA Consulting ,we offer a number of services.
Perhaps the productivity of employees would improve
if we reengineered your business.
Maybe all your bussiness needs is fresh mission
statement ,or a new batch of buzzwords.";
$services->SetContent($content);
$services->Display();
?>
please help me!!
thanks in advance



Reply With Quote




Bookmarks