So I was reading in the Codeigniter user guide and they say that:
You can also pass parameters stored in a config file. Simply create a config file named identically to the class file name and store it in your application/config/ folder. Note that if you dynamically pass parameters as described above, the config file option will not be available.
I have a config file set up with the identical name as my library and I am wondering how I can access the contents of that file. Do I need to load the config before loading the lib? Do all of the variables need to be elements of an array?
examples:
-- Config file --
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$var1 = "Variable 1";
$var2['name'] = "foo";
$var2['title']= "bar";
$var2['content'] = "Lorem ipsm dolar sit imut";
-- Library file --
class Library
{
var $data;
function __construct($data)
{
$this->data = $data;
}
}
-- Then something along the lines of --
function __construct() {
parent::__construct();
$this->load->library("library");
}
function index()
{
var_dump($this->library->data);
}
(Yes I figure the name Library is reserved but this is an example)
Shouldn't the var_dump simply dump the contents of the config file? What am I doing wrong?
$this->config->item('name');- And i think you need arrays. So$var = "variable";won't work.