How to set and get config item value in Codeigniter?

By Hardik Savani | February 15, 2018 | | 5615 Viewer | Category : PHP Codeigniter

Today, i would like to share with you how to set config item value in our codeigniter project. as well as i will share with you how to read that variable value that way we can use global variable in codeigniter 3 application.

We may need to define some global item like site url, site title, site meta data etc that way we can use it in our whole application. So here is very simple and basic example i am going to give you to define set and get config item value in Codeigniter 3 application.

we will use "$this->config" variable for set configuration item value. we will use "set_item()" and "item()" method for set and get value of array key.

So let's see very basic and simple example for config file item value.

Set Config Value:


Get Config Value:

$mainURL = $this->config->item('mainURL');

Example Config Value:


$mainURL = $this->config->item('mainURL');



I hope it can help you....

Please Subscribe Your Email Address, We Will Notify When Add New Post:

We are Recommending you: