How to call codeigniter controller function from view

后端 未结 14 1756
小蘑菇
小蘑菇 2020-11-27 05:53

How to call codeigniter controller function from view? When i call the function in a controller, get a 404 page.

14条回答
  •  旧巷少年郎
    2020-11-27 06:43

    You can call controller function from view in the following way:

    Controller:

    public function read() {
        $object['controller'] = $this; 
        $this->load->view('read', $object);
    }
    

    View:

    // to call controller function from view, do
    $controller->myOtherFunct();
    

提交回复
热议问题