Reputation: 5848
I am trying to load a custom config in codeigniter 3
$this->config->load('test')
test.php file is available in application/config
folder with following content.
<?php
$config['item_test']='sample config item';
I will get the following error
The configuration file test.php does not exist.
Codeigniter version:3.1.0
Upvotes: 1
Views: 6821
Reputation: 84
Create new file name test.php in application/config folder.
application/config/test.php
<?php
$config['gender'] = array('Male', 'Female');
?>
controllers/filename.php
class Stackoverflow extends CI_Controller{
function __construct() {
parent::__construct();
$this->config->load('test'); //loading of config file
}
function index(){
print_r($this->config->item('gender')); //Calling of config element.
}
}
Output
Array ( [0] => Male [1] => Female )
Upvotes: 5