PHP Development-Use of templates

Source: Internet
Author: User

  Through this evening more than half an hour of teacher Zhao's introduction to the template, roughly on the use of the template, structure and development of the idea of the template has a general understanding.

  Why develop a template : A template is an object that encapsulates the things that PHP uses and needs to manipulate during the process. To improve the logical structure of the code so that it does not have to overwrite the code again (that is, to improve the reuse of the code). Also facilitates the subsequent development process modification and debugging.

  the idea of developing a template: templates are developed based on the idea of object-oriented and MVC design Patterns , so template development is based on three major features (encapsulation, Inheritance and polymorphism) and the idea of a hierarchical deployment of systems by MVC. First, everything that is going to be manipulated is encapsulated as an object, defined in the M layer, and then, in the C layer, the data passed from the V layer to the M-Layer encapsulated object for logical judgment and data processing; Finally, the results of the processing are returned to the V-tier to the user.

  template structure: template structure is designed according to the MVC design pattern, the operation of the things encapsulated into objects (M layer), through inheritance simplifies the structure of the Code and improve the code reuse rate, by instantiating the object and call the appropriate method to operate on the specific things, to achieve the realization of the object, This is the C layer, the V layer is responsible for receiving requests sent by the user (data), and then send the request to the M layer for business logic judgment, and then return different results according to the business logic to the V layer presented to the user. The MVC design pattern will clearly divide the system, make the structure clear, facilitate the development of complex projects and follow-up modification and maintenance.

PHP Development-Use of templates

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.