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 ~