devi
devi

Reputation: 13

How can I add parameter to config variable in codeigniter?

I am new to php and trying to add parameter to config variable. In my example, I am defining success/error messages in config file. I am able to access the config variable using:

$this->config->item('msg') 

But I would like to add parameter in the message and pass it using:

 $this->config->item 

How can I do that?

Any help greatly appreciated.

Upvotes: 0

Views: 667

Answers (2)

Farhan
Farhan

Reputation: 1483

https://ellislab.com/codeigniter/user-guide/libraries/config.html

After dynamically setting my config variable in codeigniter how to access them from other controllers and models?

$this->config->set_item('item_name', 'item_value');

For example

$this->config->set_item('msg', 'Your Value goes here');

You can print this like this way

echo $this->config->item('msg');

Upvotes: 1

Balu
Balu

Reputation: 23

$this->config->item() works fine.

For example if there's $config['foo'] = 'bar'; in the config using $this->config->item('foo') will be 'bar'

Upvotes: 1

Related Questions