Note: CodeIgniter. Precautions for using the CodeIgniter View. This document describes the precautions for using the codeigniter view. For your reference, refer to the following: precautions for using the CI view diagram: applicationvi CodeIgniter View: codeigniter
This article describes the precautions for using the CodeIgniter view. We will share this with you for your reference. The details are as follows:
In CI, the visual view is the template file under application/views/. PHP can be used directly in the template. Therefore, the implementation of the template is not much to mention. Note the following points for the view:
1. the CI view can load multiple views in the controller. The Page finally combines the content and outputs it. If the load action is handed over to the controller, you need to adjust the controller when you need to adjust the template structure. this is not very good. It can be encapsulated in the controller or directly submitted to the view to ensure that each ACTION loads only one view file.
2. let the View do what it is good at. do not define HTML directly in PHP code. This will make it difficult to maintain programs and views. if you want to load HTML, it can be returned by load.
3. Although the get_instance method is omnipotent, do not directly read data or do some other tasks in the view. The role of a view is to receive and present data to ensure that people do their best and make the best use of the data.
4. if you want to use templates, you may prefer to use them. When using PHP directly, you need to handle variable definition issues and convert them to HTML entities. templates can solve these problems and provide more convenient operations. If efficiency problems are to be discussed, most of them are not in PHP.