codeigniter Creating and calling a library


Example

In order to use libraries in CodeIgniter, you need to create a library.

class Pro {
  function show_hello_world()
  {
    return 'Hello World';
  }
}

In this library, which is called is pro.php, this file must be added to the following path.

Path: \xampp\htdocs\project\application\libraries

Now you can use it in your controller. Code to load this library in the controller:

$this->load->library('pro');

Code to use the library functions:

class Admin extends CI_Controller {
    function index()
    {
        $this->load->library('pro');
        echo $this->pro->show_hello_world();
    }
}