CodeIgniter Forums
question about libraries.. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: question about libraries.. (/showthread.php?tid=32095)



question about libraries.. - El Forum - 07-13-2010

[eluser]mangpeps[/eluser]
Guys. I tried to create one libraries and it was successful. Problem is when I tried to return variables from the MASTER_Controller libraries, I can't use it. Here is the code. I wounld like to u
se the $header variables in all of my controllers that. Pls help

Code:
<?php
class MASTER_Controller extends Controller{

    //public $globaldata['helloworld'] = "THIS STRING IS AVAILABLE TO ANY PAGES";

    function MASTER_Controller(){
         parent::Controller();
             //$this->load->library('encrypt');
            $this->load->library('session');
    }
    
    function master_login($username,$password){
        
        
        
                $header['headlog']=null;
        
              $header['headlogout']=$this->sessioncheck();
    $header['headlogout']=TRUE;    
    
        return $header;
}



question about libraries.. - El Forum - 07-13-2010

[eluser]InsiteFX[/eluser]
The name is MY_Controller not MASTER_Controller unless you change it
in the config file.

InsiteFX


question about libraries.. - El Forum - 07-14-2010

[eluser]mangpeps[/eluser]
Yeah. I changed it in the config file. You did not give me the answer, how can I call the variable from the library ?


question about libraries.. - El Forum - 07-14-2010

[eluser]danmontgomery[/eluser]
Code:
class MASTER_Controller extends Controller {

    var $foo = 'bar';

    function MASTER_Controller() {
        parent::Controller();
    }

}

class Example extends MASTER_Controller {

    function index() {
        echo $this->foo; // bar
    }

}



question about libraries.. - El Forum - 08-22-2010

[eluser]CI_avatar[/eluser]
you may access your library variable this way.
$this->load->library('mylibrary');
$this->mylibrary->mylibraryvariable;