The only object oriented programming experience I have is from C#, so PHP is throwing me some curve balls I could use some help with.
I have a class I use for all my pages, the "pagebase" if you will. It handles the lowest level html structure. That class is inherited by several other classes. Those classes are the different page types the site has. Now: I'm having trouble setting a variable in the "pagebase" from the instance of the class that inherits it. In C# that would be no problem seeing as the class instance behaves as if it were the inherited class.
This is a representation of what I've got:
pagebase.php
<?php
class pagebase
{
var $title = "No title";
var $body = "<center>No content</center>";
function setTitle($value) {
$this->title = $value;
}
function setBody($value) {
$this->title = $value;
}
function updateHTML()
{
...
}
function drawPage()
{
$this->updateHTML();
echo $this->html;
}
}
?>
std_page.php
<?php
include("includes/pagebase.php");
class std_page extends pagebase
{
function std_page()
{
...
}
function updateHTML()
{
parent::setBody(
"
<div id=\"main_wrapper\">
The page goes here!
</div>
"
);
}
function drawPage()
{
$this->updateHTML();
parent::drawPage();
}
}
?>
index.php
<?php
include "includes/std_page.php";
$page = new std_page;
$page->setTitle("Avesta");
$page->drawPage();
?>
Now among other things, the biggest problem here is that NOTHING WORKS. The values in pagebase aren't changed even though I'm getting no error indicating the function wasn't found or run in any shape, way or form.
Someone please just inform me what I'm doing wrong - Thanks