Calling other function in the same controller?

In PHP, you can call a function within the same controller by simply calling the function name followed by parentheses. For example, if you have a function called function foo(), you can call it within the same controller like this:

foo();

If you need to call a function from a different controller, you will need to include or require the file that contains the function and then call the function using the correct namespace or class name. For example:

<?php

namespace MyApp\Controllers;

class FooController
{
  public function foo()
  {
    // Do something
  }
}

Watch a course Learn object oriented PHP

To call the foo() function from a different controller, you can use the following code:

use MyApp\Controllers\FooController;

$foo = new FooController();
$foo->foo();

This will call the foo() function within the FooController class.