CodeIgniter Forums

Full Version: Calling different functions from one Controller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]dtechplus[/eluser]
Hi all, I'm new to CI and RAD frameworks so if this sounds like a silly question pardon me. I want to have some (private) functions perform some action and then return some variables, then be able to call the function from another function in the same controller with the returned variable.

Maybe a little illustrative code will make this clearer;
This is what I want to do


Code:
class Code extends Controller
{

    function Code()
  {
        parent::Controller();
        $this->load->model('codemodel');
        
  }
  

  function _get($x)
  {
   $x = round($x / 86400);
   return $x; //this private function returns a value $x
              //which is used by function usex below
  }

  function usex($x)//this is an accessible/public function
  {
   get($x);
    echo $x;
  }
  {

Hope code above shows what I want to do
Is this possible in CI?
And BTW what's the best server config for developing standalone apps in CI (like bambooinvoice) ?

El Forum

[eluser]Crafter[/eluser]
Code:
$result = $this->get($x);
echo $result;