Articles → PHP CODEIGNITER → Create A Custom Library In Codeigniter
Create A Custom Library In Codeigniter
Example
- Create a new file inside the "libraries" folder.
- The name of the file is "MyLib.php" (you can give any name).
- Write the following code inside the file "MyLib.php"
<?php
class MyLib
{
public function MyFunc()
{
echo "Calling MyFunc";
}
}
- Now call the class inside the controller using the following code
$this->load->library('mylib');
$this->mylib->MyFunc();
Click to Enlarge