The undefined constant question isn't a new one, and I've tried Google already and found a million answers involving arrays with missing quotes and that's not my solution. I'm learning OOP coding with PHP and this is literally my first few hours working with it. This is the class I created.
class template {
var $page;
function __construct() {
$this->page = 'home';
}
function getHeader($header = 'header') {
include ('template/'.$header.'.php');
}
function getFooter($footer = 'footer') {
include ('template/'.$footer.'.php');
}
function setPage($page = 'home') {
$this->page = $page;
}
function getPage() {
if(page === 'home') {
include('template/home.php');
} else {
include('template/'.$this->page.'.php');
}
}
}
And this is how I instantiated it.
include('class.template.php');
$template = new template();
$template->getHeader();
if(isset($_GET['page'])) {
$template->setPage($_GET['page']);
}
$template->getPage();
$template->getFooter();
And of course the error - Notice: Use of undefined constant page - assumed 'page' in /Applications/MAMP/htdocs/titan-up/class.template.php on line 24
This is obviously something I should spot right away that I'm doing wrong but it's late and I'm at a loss. Any help is greatly appreciated.
Edit: Any links that make the learning process easier would be greatly appreciated. I'm already going through the PHP manual on it and have a strong background in PHP, but not OOP.