CodeIgniter: autoload. php automatic loading usage analysis, codeigniterautoload. Autoload. php automatic loading usage analysis of CodeIgniter configuration. in this article, we analyze the autoload. php automatic loading usage of CodeIgniter configuration. We will share with you the usage analysis of autoload. php automatic loading in CodeIgniter configuration. codeigniterautoload
This article analyzes how to use autoload. php to automatically load CodeIgniter configurations. We will share this with you for your reference. The details are as follows:
CodeIgniter provides the automatic loading function to globally load class libraries, models, configurations, and language packs. it is quite convenient for global functions.
For example, if a global function is written in app_helper.php and needs to be loaded globally, you only need to set autoload. php:
The code is as follows: $ autoload ['helper'] = array ('app ');
Next, you can use all the configurations, such as configuration and model. However, it is convenient to consider the disadvantages of this loading method.
If a project is divided into two parts, such as the foreground and background, is this function required? If there are different business modules in the front and back end, is it required for each module?
If you need it all, it is good to write it here. if you don't need it, it is not recommended to write it here.
Related class libraries and function calls should be loaded as needed
There are many ways to load data. you can load data on a specified page or in a public controller or function. once load is enabled, it can be used globally. My common practice is to ignore this file and manually load global functions.
Let's talk about the CI loading mechanism. The following describes how to load class libraries and functions:
$this->load->library('session');$this->load->model('hello_model');$this->load->helper(array('url', 'array'));$this->load->language(array('user_menu', 'user_tips'));
The loading method is uniform and easy to use, but it is inconvenient to pass parameters during the load class library. When the class library is loaded again, it will not be loaded again, but will be taken out from the saved static array. pay attention to the status of member attributes to Prevent program exceptions due to the existence of values.