I am trying to create a simple MVC for my personal use, and I really could use the answer to this simple question
class theParent extends grandParent{
protected $hello = "Hello World";
public function __construct() {
parent::__construct();
}
public function route_to($where) {
call_user_func(array("Child", $where), $this);
}
}
class Child extends theParent {
public function __construct() {
parent::__construct();
}
public function index($var) {
echo $this->hello;
}
}
$x = new theParent();
$x->route_to('index');
Now Child::index()this raises a fatal error: Using $this when not in object contextbut if I used echo $var->hello, it works fine.
I know that I can use $varto access all the properties in the parent, but I would prefer to use $this.
source
share