Home > Backend Development > PHP Tutorial > CodeIgniter configuration autoload.php automatic loading usage analysis, codeigniterautoload_PHP tutorial

CodeIgniter configuration autoload.php automatic loading usage analysis, codeigniterautoload_PHP tutorial

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

CodeIgniter configuration autoload.php automatic loading usage analysis, codeigniterautoload

This article analyzes the CodeIgniter configuration autoload.php automatic loading usage. Share it with everyone for your reference, the details are as follows:

CodeIgniter has an automatic loading function, which can globally load class libraries, models, configurations, language packages, etc., which is very convenient for functions that need to be used globally.

For example: There is a global function written in app_helper.php. If you need to load this function globally, you only need to set autoload.php:
Copy code The code is as follows: $autoload['helper'] = array('app');
Next, all places can be used, with similar configurations, models, etc. But while it is convenient, you also need to consider the disadvantages of this loading method.

If a project is divided into two parts, such as the frontend and the backend, is this function required for both the frontend and the backend? If there are different business modules for the front and backend, does each module need to be used?

If it is necessary, then it is good to write it here. If it is not needed, it is not recommended to write it here.

Relevant class libraries and function calls should be loaded on demand

There are many ways to implement loading. You can load on a specified page, you can load in a public controller or function, and you can use it globally once loaded. My common practice is to ignore the file and manually load global functions, etc.

Speaking of which, by the way, let’s talk about the loading mechanism of CI. The following is the loading method of class libraries, functions, etc.:

$this->load->library('session');
$this->load->model('hello_model');
$this->load->helper(array('url', 'array'));
$this->load->language(array('user_menu', 'user_tips'));

Copy after login

The loading method is unified and relatively simple to use, but it is a bit inconvenient to pass parameters when loading the class library. When loading the class library again, it will not be loaded again, but will be taken out from the saved static array. You need to pay attention to the status of the member attributes to prevent program exceptions because the values ​​still exist.

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

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 configuration database.php usage example analysis
  • CodeIgniter configuration SESSION usage example analysis
  • CodeIgniter configuration Routes.php usage example analysis
  • CodeIgniter configuration config.php usage example analysis
  • CI (Codeigniter) Setting enhanced configuration class example
  • Smarty3 basic configuration used in CodeIgniter
  • Configuring the codeigniter framework method under Nginx
  • CI (CodeIgniter) framework configuration
  • Detailed introduction to the basic configuration of CodeIgniter
  • Parsing the CodeIgniter custom configuration file

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1094758.htmlTechArticleCodeIgniter configuration autoload.php automatic loading usage analysis, codeigniterautoload This article analyzes the CodeIgniter configuration autoload.php automatic loading usage. Share it with everyone for your reference...
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