I have a problem with a constructor in a class that i'm using as a controller
I want URLs to point to the controller then i will read the query string in the url. Based on the query string in the URL, i will decide to execute/run a given method which then can carry out certain steps and/or load a page.
The url takes the form of;
domain.com/folder/property_type.php?r=addrec
This is how the controller looks
<?php
foreach(glob("../model/*.php") as $filename) {
include_once($filename);
}
class Property_type_controller{
function __construct()
{
$query_string = $_GET['r'];
if ($query_string == "addrec")
{
$this->property_type_add();
}
else if ($query_string == "procadd")
{
$this->property_type_added();
}
else if ($query_string == "view")
{
$this->property_type_view();
}
}
function property_type_add()
{
header('HTTP/1.1 200 OK');
header('Connection: close');
include_once '../view/property_type_add.php';
}
}
?>
It should load the "property_type_add" page using the include but it fails to.
I get a blank page and even the browser's view source is blank.
Could you help me figure out the problem. Is this the right way to get a class constructor method to execute by default when accessed in PHP ?