Home > Article > Backend Development > Analysis on the usage of $this->load->library() in CI framework
This article mainly introduces the usage of $this->load->library() in the CI framework, and analyzes in detail the steps and related precautions for loading the library method. Friends in need can refer to it
This article analyzes the usage of $this->load->library() in the CI framework. I share it with you for your reference. The details are as follows:
My first loading failed. It turned out that the file name and class name were different. Let me first summarize the precautions for CI loading your own class files:
1. Third-party loading files 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 and the class name should be Excel
3. Pass: $this->load->library('class');Load where you need
4. You can also load it in application/ Load in config/autoload.php, add
$autoload['libraries'] = array('Excel');
5 to the file. When loading, if libraries have multiple folders, such as myfile, it can be loaded in the following way:
$this->load->library('myfile/类');
6. The second parameter can place parameters as follows:
$config = array ( 'mailtype' => 'html', 'charset' => 'utf-8, 'priority' => '1' );
$this->load->library('email', $config);
7. The third parameter can use your customized name as follows:
$this->load->library('session', '', 'my_session'); // Session 类现在可以通过下面的方式访问: $this->my_session ->set_userdata("session名","session值");
The above is The entire content of this article is hoped to be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
About the method of using session-cookie in php and codeigniter
About the method of operating redis in CI framework
The above is the detailed content of Analysis on the usage of $this->load->library() in CI framework. For more information, please follow other related articles on the PHP Chinese website!