Get Custom Added Config Value in Codeigniter

In Codeigniter we can added any number of config variables for the site. Follow the step to add and retrieve the value of custom added config variable.

1. Define the config variables in config.php in ‘application/config’ folder

$config['config_variable1']	= 'Config value 1';
$config['config_variable2']	= 'Config value 2';
$config['config_variable3']	= 'Config value 3';

2. To get these values in the view files located in ‘application/views’

$config_variable1 = $this->config->item('config_variable1');
$config_variable2 = $this->config->item('config_variable2');
$config_variable3 = $this->config->item('config_variable3');

Leave a Comment

DON’T MISS OUR GIVEAWAYS!
Subscribe To Newsletter
Subscribe to our newsletter and get all the latest updates offers and giveaways right in your inbox.
Subscribe
Give it a try, you can unsubscribe anytime.
close-link

Join Free Giveaway!

Subscribe to our newsletter to get latest offers and giveaways!
SUBSCRIBE
close-link