How to call codeigniter controller function from view

keerthi picture keerthi · Apr 3, 2012 · Viewed 140.3k times · Source

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

Answer

saad picture saad · Jun 20, 2014

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();