Understanding MVC Views in PHP

2018-12-31 10:09发布

I have to seem problems grasping the concept of Views in MVC, they are, according to what I've read, the layer that manages the presentation in the aplication, but many of the material I've been reading seem to be different regarding this matter in this one from PHP Master.com.

The View is a class with functions that return some HTML code, where is the rest of my HTML? should it be put in independent .html pages that access this View code?

In this article, from php-html.net the View is a simple HTML file with a .php extension, but how are they accessing that data? I see no require() or anything like the instantiations in the first tutorial.

7条回答
弹指情弦暗扣
2楼-- · 2018-12-31 10:54

When the browser calls a page, a controller will be loaded for this one. The controller manages the lifecycle of your app. He'll grab data from the model, which is only used to get data (maybe from a database). The View is only HTML, the controller will echo the view, and if neccessary, pass a few parameters to it.

查看更多
登录 后发表回答