In the CI framework, $ this-> load-> library () usage analysis, this-load-
This article analyzes the usage of $ this-> load-> library () in the CI framework. We will share this with you for your reference. The details are as follows:
I failed to load the file for the first time. It turns out that the file name is different from the class name. First, I would like to summarize the considerations for CI loading your own class files:
1. Third-party file loading should be placed under the application/libraries File
2. The file name and class name should be the same, and the first letter should be capitalized. For example, the file name Excel. php class name should be Excel
3. load data in the following way: $ this-> load-> library ('class ');
4. You can also load the file in application/config/autoload. php.
$ Autoload ['libraries'] = array ('excel ');
5. When loading, if libraries has multiple folders, for example, myfile can be loaded as follows:
$ This-> load-> library ('myfile/class ');
6. The second parameter can be placed as follows:
$ Config = array ('mailtype' => 'html', 'charset' => 'utf-8, 'priority '=> '1 ');
$ This-> load-> library ('email ', $ config );
7. The third parameter can use your custom name as follows:
$ This-> load-> library ('session ', '', 'My _ session'); // The session class can be accessed in the following way: $ this-> my_session-> set_userdata ("session name", "session value ");