[eluser]whygod[/eluser]
This is MY_Controller below,
Code:
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Controller extends CI_Controller
{
public $data = array(
'username' => '',
'message' => '',
'member_menu' => '',
);
public $cookie_life = '';
public $cookie_dname = '';
function __construct ()
{
parent::__construct();
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('jaz_lib');
$this->load->model('jaz_model');
$this->config->load('jaz_config');
//fetching data from config
$this->cookie_life = $this->config->item('cookie_life');
$this->cookie_dname = $this->config->item('cookie_dname');
}
function show_config()
{
echo ':MY_Controller:';
echo '<br>Cookie Life: ' . $this->cookie_life;
echo '<br>Cookie Dname: '. $this->cookie_dname;
}
}
And now I created a library jaz_lib.php
I tried to access the variables from MY_Controller,
using these codes below in the jaz_lib.php
Code:
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Jaz extends MY_Controller
{
//Data types declaration.
public $data = array();
public $main_url = '';
public $base_cont;
function __construct()
{
parent::__construct();
//loading classes
$this->load->helper('general');
$this->load->helper('url');
$this->load->helper('cookie');
$this->load->model('users_model');
$this->load->library('email');
//assining values to variables.
$this->main_url = base_url() . 'jaz/';
//Create an object with MY_Controller class
$base_cont = new MY_Controller;
}
function show_config2()
{
echo 'Cookie Life: ' . $base_cont->cookie_life;
echo '<br>Cookie Dname: '. $base_cont->cookie_dname;
}
}
Noticed I'm trying to access $cookie_life and $cookie_dname from MY_Controller class.
But it doesn't work.
What is the proper way to access the properties from MY_Controller inside a library class?
Any help please.
Thanks in advanced.