MVC is a software approach for separating the logical and presentation layers of an application. In practice, because of this separation, your page contains only a few PHP scripts.
The model represents your data structure. Typically, the model class will contain methods that help you to make the database more censored.
A view is a message to be presented to a user. A view is usually a Web page.
A controller is a mediation between a model, a view, and any other resource necessary to process an HTTP request, and generates a Web page.
Homemade a simple MVC model.
1. Entry file index.php
The only script file that allows the browser to request directly
2. Controller controllers
Reconcile Models and views
3. Model
Provide data, save data
4. Views view
Responsible for displaying Web pages
5. Actions action
A method in the controller used by the browser to request
--------------------folder Structure-------------------------
Home Folder Mvc_demo
--controllers
--articlecontroller.php
--UserController.php
--models
--usermodel.php
--views
--user/index.php
index.php//Entry file
-----------------------------------------------------------
index.php
$a ();
controllers/
UserController.php
Usercontroller{public function Index () {//echo "This is the user controller's index method";//contains the file and instantiates a model include './models/usermodel.php '; /Get data by model $model = new Usermodel (); $str = $model->getuser (); include './views/user/index.php ';}}
models/usermodel.php
views/user/index.php
Enter Http://localhost:8080/mvc_demo/index.php?c=User&a=index in the browser to display the effect of the user Helen.
The above describes a simple MVC model, including the UserControl aspects of the content, I hope the PHP tutorial interested in a friend helpful.