Analysis on the usage of $this->load->library() in CI framework

不言
Release: 2023-04-01 08:08:01
Original
3661 people have browsed it

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');
Copy after login

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/类');
Copy after login

6. The second parameter can place parameters as follows:

$config = array (
 'mailtype' => 'html',
 'charset' => 'utf-8,
 'priority' => '1'
);
Copy after login
$this->load->library('email', $config);
Copy after login

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值");
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!