While trying to learn about MVC in PHP, I came across this site : https://r.je/mvc-in-php.html, where I wanted to test one of the examples it gave. And this is the error message I get
Notice: Trying to get property of non-object in /opt/lampp/htdocs/webs/train/mvc/helloWorld.php on line 19
Here's the code:
<?php
class Model {
public $text;
public function __constructor() {
$this->text = "Hello World";
}
}
class View {
private $model;
public function __constructor(Model $model) {
$this->model = new Model();
}
public function output() {
return "<h1>" . $this->model->text . "</h1><br>";
}
}
class Controller {
private $model;
public function __constructor(Model $model) {
$this->model = $model;
}
}
$model = new Model();
$controller = new Controller($model);
$view = new View($model);
echo $view->output();
?>
Please any help?