I have some pages like a.php, b.php, c.php
Each php file has the following constructor function.
var database;
function __construct() {
$database = $this->router->database;
}
What I want to do is:
function __construct() {
$this->router->construct();
}
So, the construct() function in my router should create a $database variable with “$this->router->database” assigned to it. I should be able to $database->query() without any other changes in my controller.
How can I do this? It probably has a very very basic reply but I am pretty confused right now, even thinking about eval().
Any help would be greatly appreciated.
I’m a bit fuzzy on what you’re actually trying to accomplish, but it sounds like you’re trying to eliminate the duplicate constructors for all of those pages. If that’s the case, then you could create a parent class and put in the appropriate code and then inherit each of your other pages from the parent class.
and your other files would just need