_php Example of $this->load->library () usage analysis in CI framework

Source: Internet
Author: User
Tags autoload php class codeigniter custom name zend framework

This paper analyzes the usage of $this->load->library () in CI framework. Share to everyone for your reference, specific as follows:

The first time I failed to load, originally is the file name and class name for different reasons, first summed up about CI loading your own class file considerations:

1. Third party loaded items should be placed under Application/libraries documents

2. FileName and class name should be the same, and the first letter uppercase, such as FileName excel.php class name should be Excel

3. Adoption:$this->load->library (' class '); The way to load where you need it

4. Can also be loaded in the application/config/autoload.php, add in the file

$autoload [' libraries '] = Array (' Excel ');

5. When loading, if libraries has more than one folder, such as myfile can be loaded in the following way:

$this->load->library (' myfile/class ');

6. The second parameter can be placed in the following way:

$config = Array (
 ' mailtype ' => ' html ', '
 charset ' => ' utf-8,
 ' priority ' => ' 1 '
);

$this->load->library (' email ', $config);

7. The third parameter can use your custom name in the following way:

$this->load->library (' Session ', ', ' my_session ');
The session class can now be accessed in the following way:
$this->my_session->set_userdata ("Session name", "Session value");

More interested in CodeIgniter related content readers can view the site topics: "CodeIgniter Introductory Course", "CI (CodeIgniter) Framework Advanced Course", "PHP Excellent Development Framework Summary", "thinkphp Introductory Course", " Thinkphp Common Methods Summary, "Zend Framework Introduction Course", "PHP object-oriented Programming Introduction Course", "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design based on CodeIgniter framework.

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.