CodeIgniter Forums

Full Version: How to access $config array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Hello,

I'm trying to get value which set at config.php from my controller:
Code:
$config['base_url'] = "http://localhost/ci/";

Now I do it like this:
Code:
$this->config->config['base_url']

Is there any better way instead specifying 'config' twice?

Thanks

El Forum

[eluser]theprodigy[/eluser]
According to the Config Class Docs:
Code:
$this->config->item('item name');

El Forum

[eluser]Unknown[/eluser]
True, thank you very much

El Forum

[eluser]Atharva[/eluser]
you can use
Code:
base_url()
function to get base_url set in config.php

El Forum

[eluser]Aken[/eluser]
Alternatively, config_item('item') is available globally without loading any additional resources.