Home > Backend Development > PHP Tutorial > Things to note when using CodeIgniter views, codeigniter_PHP tutorial

Things to note when using CodeIgniter views, codeigniter_PHP tutorial

WBOY
Release: 2016-07-12 09:00:08
Original
903 people have browsed it

CodeIgniter view usage precautions, codeigniter

This article describes the CodeIgniter view usage precautions. Share it with everyone for your reference, the details are as follows:

The view in CI is the template file under application/views/. The template supports the direct use of PHP, so there is not much to say about the implementation of the template. Here are some things to note about views:

1. The CI view can load multiple views in the controller, and the page will finally combine these contents and output them. If the load action here is left to the controller, the controller will need to be adjusted when the template structure needs to be adjusted, which is not good. It can be encapsulated in the controller or directly handed over to the view to ensure that each ACTION only loads one view file.

2. Let the view do what it is good at. Do not define HTML directly in the PHP code. This will make it difficult to maintain both the program and the view. If you want to load HTML, you can return it through load.

3. Although there is a universal get_instance method, do not directly read data or do other module things in the view. The role of the view is to receive data and display it to ensure that people fulfill their responsibilities and things are put to their best use.

4. Regarding the question of whether to use templates, I personally tend to use templates. When using PHP directly, you need to deal with the definition of variables and the problem of converting to HTML entities. Templates can solve these problems and provide some more convenient operations. If we want to talk about efficiency issues, they are not here, and most of them are not in PHP.

Readers who are interested in more content related to the CodeIgniter framework can check out the special topics on this site: "Introduction to codeigniter tutorial" and "Advanced tutorial on CI (CodeIgniter) framework"

I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.

Articles you may be interested in:

  • CodeIgniter custom controller MY_Controller usage analysis
  • Codeigniter controller controller inheritance problem example analysis
  • 2 Codeigniter Example of writing batch file upload controller
  • Detailed explanation of CodeIgniter hook usage example
  • CodeIgniter configuration database.php usage example analysis
  • Detailed explanation of CodeIgniter multi-language implementation method
  • CI (CodeIgniter) model usage example analysis
  • Detailed explanation of the codeIgniter read-write separation implementation method
  • CI (CodeIgniter) simple statistics of the number of visitors implementation method
  • Business logic of the CodeIgniter controller Example Analysis

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1094769.htmlTechArticleCodeIgniter view usage precautions, codeigniter This article describes the CodeIgniter view usage precautions. Share it with everyone for your reference, the details are as follows: The view in CI is application/vi...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template