Learn PHP notes one

Source: Internet
Author: User

First day
Definition of MVC
Model View Controller
Quickly get started with major mainstream frameworks to quickly adapt to the Wen development needs of most companies
MVC solves the problem database----array-----loops--output
Database code HTML code PHP code mixed together, poor maintenance and lead to wasted time.

The advantages of MVC
MVC's three layers do not interfere with each other to benefit people's Division of labor
View Web designer model business familiarity with people controller other developers
Reuse of code
The composition and operation Principle of MVC
View: Visually capable of viewing the interface directly HTML code Flash XML
Controller: Tools and helpers to issue instructions to the system
Model: Extract data from the database as required
Workflow for MVC
The first step: the browser---Call the controller, give him instructions
Step TWO: Controller---Select a suitable model according to the instruction
The third step: Model---Take the corresponding data according to the control instruction
Fourth step: Controller--Select the corresponding view according to the instruction
Fifth step: View-the corresponding output according to the instructions of the Controller
The development of the program to standardize the unification,
Making the first controller program
testController.class.php Name controller file class file
<?php
Class testcontroller{
Function Show () {
$testModel = new Testmodel ();
$data = $testModel, get ();
$testView = new TestView ();
$testView->display ($data);
}
}
The first model of the program testModel.class.php
<?php
Class testmodel{
function Get () {
Return "Hello world!";
}
}

Making the creation of the first view file
testView.class.php
<?php
Class testview{
function display ($data) {
Echo $data;
}
}
How to make these files work together
test.php
<?php
Require_once "testController.class.php"; Require will make an error on the problem so it is recommended to use require instead of inlclude
Require_once "";
Require_once "";
$testController = new TestController ();
$testController->show ();

Learn PHP notes one

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.