• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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, 10:31 PM
Newbie Help w/ Constructors - by El Forum - 11-02-2010, 10:58 PM
Newbie Help w/ Constructors - by El Forum - 11-02-2010, 11:38 PM
Newbie Help w/ Constructors - by El Forum - 11-02-2010, 11:40 PM
Newbie Help w/ Constructors - by El Forum - 11-03-2010, 12:21 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.