Home > Backend Development > PHP Tutorial > Understanding MVC, MVC understanding_PHP tutorial

Understanding MVC, MVC understanding_PHP tutorial

WBOY
Release: 2016-07-12 08:51:23
Original
1252 people have browsed it

Understanding of MVC, MVC understanding

Abstract: This article mainly talks about the understanding of the MVC development model in PHP development.

When a user triggers a command through a url, such as url=http://control.blog.sina.com.cn/admin/article/article_add, this means entering the admin.php file in the bolg project and calling the framework file For example, in the ThinkPHP framework, find the article.class.php file, where article is a controller class, inherited from controller (TP3.2), and article_add is a method that processes the parameters passed by the user through the URL. This is the control layer!

When the method passes the passed parameters such as db_blog, it will find the pile of tables called blog in the database. Through db_Username, find the Username table in the blog. This is the business layer. But in MVC, the business layer and model layer are often merged.

The legendary model layer is actually the addition, deletion, checking and modification of the database.

2014-02-25

PS: MVC, M refers to the Model layer, that is, the model layer. The initial design is the data or information that the program needs to operate, that is, some common operations related to the database are written. Inside the model layer. For example, write queries to the database in it. However, it does not have to be written in it. In actual development, for convenience, it can be written in the control layer. As long as it can operate effectively on the database, the effect is the same. This does not mean that the model layer is redundant. You can encapsulate frequently used operations in it. For example, query queries can add utf-8 to gbk operations, and so on.

V refers to the View layer. Mainly refers to the final result we send to the web browser - such as the HTML generated by our script. When it comes to views, many people think of templates. The so-called templates are HTML pages made by others. You can just integrate the template into our system. Generally, you only need to add tags to it, and the control layer throws the variables to the view layer, where the URL parsing specifications are set according to each system. The label is to parse the thrown variable into the result and then display it.

C refers to the control layer controller. The main business logic of a system is written in the control layer. The data is submitted to the control layer through the view layer. After processing by the control layer (including processing or operations on the database or interaction with the model layer), the data can be sent to the view layer for display or the database can be updated.

A simple example reference: http://www.jb51.net/article/60796.htm

Organized on 2016.5.21

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1130483.htmlTechArticleUnderstanding of MVC, MVC understanding summary: This article mainly talks about the understanding of the MVC development model in PHP development. When a user triggers a command through a url, such as url=http://control.blog.sina.com.cn/a...
Related labels:
mvc
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template