CodeIgniter View usage notes, codeigniter_PHP tutorial

Source: Internet
Author: User
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.

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.