Ec (2); the main task of the view layer in MVC mode is to display pages and results. In php implementation, it is mainly embodied as a template (using a template, php code and html code separation can be achieved, so that code and page maintenance is much more convenient, easy to manage and page replacement, can truly divide the division of labor of programmers and artists) parsing process: first, the controler layer obtains data from the model layer. Second, the controler layer submits the data to the view layer. script ec (2); script
The main task of the view layer in MVC mode is to display pages and results. In php implementation, it is mainly reflected as a template (using a template, php code and html code separation can be achieved, so that code and page maintenance is much more convenient, easy to manage and page replacement, can truly divide the division of labor of programmers and artists) parsing process:
First, the controler layer obtains data from the model layer.
Second, the controler layer delivers the data to the view layer.
Thirdly, the view layer interface transmits data to the template parsing class in a certain way,
Finally, the template parsing class parses the data to the template and then displays it.
The following is an example.
Directory structure
|-ClassRenderTest. php // test classlist.html |-StudentRenderTest. php // test studentlist.html |-Render/TemplateParser. php // template parsing class |-Render/Render. php // parse the basic classes of all classes in the template |-Render/StudentRender. php // the class of the intent template studentlist.html |-Render/ClassRender. php // the class of the callback template classlist.html |-Template/studentlist.html // template File |-Template/classlist.html // template File |
Note:
1. The template parsing class uses the simple "TemplateParser. php". You can select any template parsing Class Based on your needs;
2. If "TemplateParser. php" is directly called for parsing every template, a large number of repeated code may appear, which is not allowed by oo ideas. Therefore, "Render. php" is used to pack it, and then the Render class in "Render. php" is extended to parse different file templates;
3. Different template parsing classes use different methods and their packaging methods may be different.
Required.
File 1: classlist.html
Current time is: _ now _
Current school class list:
ID |
NAME |
GRADE |
CLASS |
BEGIN_classlist _
_ Cid _ |
_ Cname _ |
_ Grade _ | & Nb
< |