Welcome Guest, Not a member yet? Register   Sign In
passing data from __construct to functions
#1

[eluser]Media Gearhead[/eluser]
So this code used to work for me in CI 1.7.* but now it is causing issues in CI 2

Worked in CI 1.7.x
Code:
class Error404 extends Controller {
    function __construct(){
        parent::Controller();
        $this->data = array('page_title','Page not found 404');
    }
    
    function index(){
        echo $this->data['page_title'];
    }
}

Doesn't work in CI 2
Code:
class Error404 extends CI_Controller {
    function __construct(){
        parent::__construct();
        $this->data = array('page_title','Page not found 404');
    }
    function index(){
        echo $this->data['page_title'];
    }
}

I am not sure what is happening that is different. I have tried changing parent::__construct(); to parent::Controller(); and parent::CI_Controller(); and every other combination I can think of.
I just want to be able to pass data from the construct to the other functions and I can't get the syntax right.


Messages In This Thread
passing data from __construct to functions - by El Forum - 02-17-2011, 11:37 AM
passing data from __construct to functions - by El Forum - 02-17-2011, 12:57 PM
passing data from __construct to functions - by El Forum - 02-17-2011, 01:10 PM
passing data from __construct to functions - by El Forum - 02-17-2011, 01:30 PM
passing data from __construct to functions - by El Forum - 02-17-2011, 04:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB