User call_user_fun to call a class method in run time.
class abc{
public $page;
public function abs123(){
print 'Humpty Dumpty sat on a wall!';
}
public function runpage(){
$this->page = 'abs123';
call_user_func(array($this, $this->page));
}
}
I actually don’t know, haha. But here’s another way to look at it…
I wouldn’t recommend it, but food for thought.
// This is how it's called:
new PageLoader('abs123');
class PageLoader
{
// This happens everytime you do a new PageLoader();
public function __construct($var)
{
// Set the page name
$this->page = $var;
// Jump to the handlePage
$this->_handlePage();
}
private function _handlePage()
{
// Call a function based on $this->page set above
switch ($this->page)
{
case 'abs123':
$this->abs123();
break;
case 'something':
$this->something();
break;
defeault 'home':
$this->home();
break;
}
}
// private functions to do all your pages.
private function abs123()
{
// do stuff
}
private function something()
{
// do stuff
}
private function home()
{
// do stuff
}
}