Mitch Evans Mitch Evans - 1 year ago 256
PHP Question

Custom config file for codeigniter

Very new to CodeIgniter, trying to create a custom config file to load special variables into my application.


I created
and placed the following code in that file:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

$gender = array ('male','female');


I then opened up
and altered the following code:

$autoload['config'] = array();

/* TO: */

$autoload['config'] = array('custom');

I refresh my application and see this error:

Your application/config/custom.php file does not appear to contain a valid configuration array.

I opened up some of the default config files and don't see a configuration array? What am I doing wrong?

Answer Source


$config['gender']= array ('male','female');

instead of

$gender = array ('male','female');

For fetching config item


Where item_name is the $config array index you want to retrieve.

Docs : CodeIgniter User Guide 2.x CodeIgniter User Guide 3.x

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download