O'Reilly logo

Programming with CodeIgniter MVC by Yehuda Zadik, Eli Orr

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining and using your own configurations

CI enables us to define our own configurations and easily access them via the config class. For example, with application/config/my_config.php, let's say we define a parameter in that config file as follows:

$param1 = "value1";

We can easily access our configuration file parameters to load all the parameters into the array:

$array = $this->config->load('my_config', TRUE);

The second parameter, TRUE, assures us that our configuration parameters will be defined in an array prefixed with the configuration file name.

Consider: $param1 = $array['my_config']['param1'];

or: $param1 = $this->config->item('param1', 'my_config');.

$param1 will have the value value1 that we have set in the configuration file that we built. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required