Codeigniter : calling a method of one controller from other

后端 未结 10 1933
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 01:48

I have two controllers a and b.

I would like to call a method of controller a from a method of controller b.

10条回答
  •  Happy的楠姐
    2020-12-05 02:39

    You can use the redirect URL to controller:

    Class Ctrlr1 extends CI_Controller{
    public void my_fct1(){
    redirect('Ctrlr2 /my_fct2', 'refresh');
    }
    }
    
    
    Class Ctrlr2 extends CI_Controller{
    public void my_fct2(){
    $this->load->view('view1');
    }
    }
    

提交回复
热议问题