In the CI framework, $ this-& gt; load-& gt; library () usage analysis, this-load-

Source: Internet
Author: User
Tags autoload

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 ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.