i am trying to set a title with the function below and then call another function so i can render the view but after I cannot see the title. here is my code:
snippet from another file:
$indexPage = new View();
$indexPage->setPageTitle('This is the title');
$indexPage->render('index');
This is my view class:
class View {
private $title;
public function render($file) {
require '/view/header.php';
require '/view/'.$file.'.php';
require '/view/footer.php';
}
public function setPageTitle($title) {
$this->title = $title;
}
}
then I would access it on my page:
index.php:
<?php echo $this->title ?>
but it does not show.