<?php
class Model
{
private $title = "Please define page's title";
private $body = "Please define page's body";
private $footer = "Please define page's footer";
public function setTitle($title)
{
$this->title = $title;
}
public function setContent($content)
{
$this->body = $content;
}
public function setFooter($footer)
{
$this->footer = $footer;
}
public function showTitle()
{
return $this->title;
}
public function showContent()
{
return $this->body;
}
public function showFooter()
{
return $this->footer;
}
}
class WebPage extends Model
{
function __construct()
{
echo '<html>';
echo '<head>';
echo '<title>';
echo $this->showTitle();
echo '</title>';
echo '</head>';
echo '<body>';
echo $this->showContent();
echo $this->showFooter();
echo '</body>';
echo '</html>';
}
}
?>
//In the indeex file
<?php
$model = new Model();
$model->setTitle("Php OOP Test");
$model->setContent("HelloWorld");
$model->setFooter("Hello");
$page = new WebPage();
?>
The problem is all title , content and footer are not changing. I try to build my own php framework :) This looks a little bit stupid lol but I am new to this kind of thing.
Aucun commentaire:
Enregistrer un commentaire