Confused by MVC post

I have some questions about the MVC posts.

Comments there are closed and redirect here.

In the view, this code looks wrong:

private $model;

public function __construct($model) {
    $this->controller = $controller;
    $this->model = $model;
}

There is no controller variable and no controller passed in.

In the page, this code looks wrong:

if (isset($model)) {
    $m = new $model();
    $c = new $controller($model);
    $v = new $view($model);
    echo $v->output();
}

Should it be passing the newly created model and controller into the view?

Otherwise, looks like a very helpful article.

Thanks,
Brad.

Yes, according to the first part of that article, which has the following line:

$view = new View($controller, $model);

Looks like author just missed to pass $controller in the second part of article.
Although, that doesn’t matter too much because the main goal of those articles is to explain the general idea of MVC.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.