Welcome Guest, Not a member yet? Register   Sign In
Newbie Help w/ Constructors
#3

[eluser]mdgrech[/eluser]
There has got to be a better way. Doing it your way would result in code like below. Which defeats the whole purpose of setting some default values that all my functions will inherit.

Code:
<?php
class Test extends Controller {

    public $message;
        
    function __construct()
    {
        parent::Controller();
        
        $this->username = "Steve";
    }
    
    
    function index()
    {        
        $data['username'] = $this->username;  
        $this->load->view('foo', $data);
    }

   function account()
    {        
        $data['username'] = $this->username;
        $this->load->view('foo', $data);
    }

}


Messages In This Thread
Newbie Help w/ Constructors - by El Forum - 11-02-2010, 09:31 PM
Newbie Help w/ Constructors - by El Forum - 11-02-2010, 09:58 PM
Newbie Help w/ Constructors - by El Forum - 11-02-2010, 10:38 PM
Newbie Help w/ Constructors - by El Forum - 11-02-2010, 10:40 PM
Newbie Help w/ Constructors - by El Forum - 11-02-2010, 11:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB