Welcome Guest, Not a member yet? Register   Sign In
How can i make my own config file?
#1

[eluser]developer10[/eluser]
i want to have a file to store my config items. what is the best way of doing this and how am i supposed to retrieve config items from it?

i tried something like this, but it didn't work (NOTE: i looked into some app and tried to replicate this):

i created a file named "app_config" and saved it in the config folder of my application.

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

$config['some_item'] = 'blah-blah-blah';

?>

then in my file "Functions" which is located in library folder, put this:

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

class Functions
{
    
    function Functions()
    {
        $this->ci =& get_instance();
        
        $this->ci->load->config('app_config');
    }
}

in my controller, i load this library
Code:
$this->load->library('functions');

Now, i try to retrieve "some_item" value from config (with or without "echo"):

Code:
$this->app_config->some_item;
Code:
$this->functions->some_item;

EDIT: neither of those ways works.


is this the correct way or i'm doing something wrong? do i really need to import config file into library file before i'm
able to use it, or there's a better solution?

Thanks!


Messages In This Thread
How can i make my own config file? - by El Forum - 12-29-2009, 01:19 PM
How can i make my own config file? - by El Forum - 12-29-2009, 01:33 PM
How can i make my own config file? - by El Forum - 12-30-2009, 03:55 AM
How can i make my own config file? - by El Forum - 12-30-2009, 08:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB