CodeIgniter Forums
How to access $config array - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to access $config array (/showthread.php?tid=42775)



How to access $config array - El Forum - 06-19-2011

[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


How to access $config array - El Forum - 06-19-2011

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



How to access $config array - El Forum - 06-19-2011

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


How to access $config array - El Forum - 06-20-2011

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


How to access $config array - El Forum - 06-20-2011

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