CodeIgniter Forums
Execute a controller function inside other controller function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Execute a controller function inside other controller function (/showthread.php?tid=18092)



Execute a controller function inside other controller function - El Forum - 04-25-2009

[eluser]Unknown[/eluser]
Is possible to execute a controller function inside other controller function.

For isntance
I have 2 controller A,B

A->foo - function controller
B->bar - function.

I want to execut in A->foo , B->bar

class A
{
function foo()
{
....
B->bar

}
}


Execute a controller function inside other controller function - El Forum - 04-25-2009

[eluser]pistolPete[/eluser]
Either search this forum for "HMVC" or use the "traditional" PHP way:

Code:
<?php
require_once('B.php');
class A extends Controller {
   function foo()
   {
      $b = new B();
      $b->bar();
   }
}

You could also turn B into a library.