MVC, mvc framework _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
MVC, mvc framework. MVC is not a technology, but an idea that separates website user operations from background user operations (including database operations. Background MVC and mvc framework
MVC

It is either a technology or an idea that separates website user operations from background user operations (including database operations.

Php in the background is always called by user behavior. you must set an operation Portal for user behavior,

Operation entry: The essence is to use a URL (only one privlege. php? Action = value, goods. php? Action = value)

Background:

Parse the URL to get the URL and judge it according to the action ==> C in MVC

Operate the database according to different actions (actions) and obtain data => M in MVC

Use include to introduce an html file (Template) for echo information to the user ==> V in MVC

 

M: (module) the model is mainly used to operate the corresponding data tables (the table class goods. class. php, category. class. php, and user. class. php)

V :( view) view is the html document used to hold php echo data

C :( controller) the controller is mainly used to process business logic and control the trend of program processes.

 

Image analogy:

The user is the company's big boss

C (privilege. php, goods. php, index. php)

 

When a user sends a command, the middle-level company receives the command (one command can be divided into multiple steps: 1. reading data is a step; 2. returning data to the user ), company middle-level school Younger Brother 1 (user. class. php, goods. class. php) to read the data, younger brother 1 returns the data to the middle-level companies, the middle-level companies then hand over the data to younger brother 2, and younger brother 2 displays the data.

 

Why should user. class. php and goods. class. php inherit the DB class.

There are only four methods to operate the database. This operation application shows different transactions in different modules. Therefore, the business of each module cannot be encapsulated in the DB class, and the model class can be used to encapsulate different services of the same website module.

 

Users operate on "unexpected" behaviors of programmers. Users can only click the button or A link, and the href of A link is designed by programmers.

MVC diagram:

Expansion:

MVC is not a technology, but an idea that separates website user operations from background user operations (including database operations. Background...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.