Php-mvc mode (2)-php Tutorial

Source: Internet
Author: User
Php-mvc mode (2) mvc mode is used to achieve better unified management and operate the entire system from the outermost side. Therefore, we need to encapsulate a unified portal file. when we need it to operate, we only need to pass in instructions to this portal file in the form of URL get, which can automatically mobilize various module functions, complete the tasks we have assigned.
First, create a function. php to define all the methods called by the system:

A function C is encapsulated here. <Direct Control> Contorller. class, input $ name, define the method to create this object, and input the method $ method to implement this method for the corresponding object.

In the encapsulation of the underlying method, only the class name $ name is passed in, but the status is controlled only in the form of a control class. That is to say, only when a specified class is instantiated can this class be activated to implement its own method, which is also indirectly controlled. We should also modify it in conroller. class. php:

Instead of creating a new class, call the defined method m v to implement class instantiation.

The Mvc level is top-down, and the upper layer does not need to know what attributes the bottom class has and how to implement them. As long as you know that the object has the required method, let this object solve the problem (instantiate this object ). How to solve the problem? That is the underlying thing. the underlying layer defines the solution.

The methods covering the entire system have been encapsulated. next we should build a unified entry, index. php

We only need to access index. php from the outside and add the class name and method to the address bar to get the desired result ~

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.