Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a controller from another controller in codeigniter?

I want to load a controller function from another controller function using codeigniter. What is the suitable way to do this so when call it url should be changed also.

like image 478
Upendra Sharma Avatar asked Aug 13 '26 11:08

Upendra Sharma


1 Answers

No You cant do it.

What you have to do it is create that function in model and call it through your controllers. So it will work fine.

Ex

In Model

function get_id()
{
   //some argument 
}

In controller 1

$this->Model_name->get_id()

In controller 2

$this->Model_name->get_id()
like image 75
Abdulla Nilam Avatar answered Aug 14 '26 23:08

Abdulla Nilam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!