How to set or get config variables in Codeigniter?

Last updated 5 years, 4 months ago | 4288 views 75     5

Tags:- CodeIgniter

Codeigniter | SET or GET config variables

The config set_item() & item() functions are work for SET and GET a config variable in codeigniter

 

In Codeigniter, by default, all config variables are located at the “application/config/config.php” file.

 


 

The config class function set_item() is used to set a variable in Codeigniter 

<?php

// Setting a config variable dynamically
$this->config->set_item('variable_name', value);

?>

 


 

The config class function item() is used to get a config variable value in Codeigniter.

<?php

// Getting value of config variable in Codeigniter.
$this->config->item('variable_name');

?>