Home > Article > Backend Development > Usage analysis of $this->load->library() in CI framework, this-load-_PHP tutorial
This article analyzes $this->load- in CI framework >Usage of library(). Share it with everyone for your reference, the details are as follows:
My first loading failed. It turned out to be because the file name and class name were different. Let me first summarize the precautions for loading your own class files in CI:
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. Load where you need by: $this->load->library('class');
4. You can also load it in application/config/autoload.php and add
to the file.$autoload['libraries'] = array('Excel');
5. 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 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 customized name as follows:
$this->load->library('session', '', 'my_session'); // Session 类现在可以通过下面的方式访问: $this->my_session ->set_userdata("session名","session值");
Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php excellent development framework summary", "ThinkPHP introductory tutorial", "Summary of Common Methods in ThinkPHP", "Introduction Tutorial on Zend FrameWork Framework", "Introduction Tutorial on PHP Object-Oriented Programming", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.