A simple MVC model

Source: Internet
Author: User
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.

  • 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.