phpaltorouter

what does this $controller::Index() mean?


Looking at a router I find this $controller::Index();, what does this mean?

$router->map( 'GET', '/[a:controller]/', function($controller, $action = 'index') {
    if( method_exists( $controller, $action ))
        $controller::Index();
    else
        echo 'missing';
});

what does this $controller::Index() mean?


Solution

  • $controller::Index();
    

    call index function of controller. Where $controller has the name of controller class. So as per oops you are calling index function by using scope resolution operator (::).