Last Updated: September 09, 2019
·
2.605K
· narven

Call current controller / method in CodeIgniter dynamically

// call current class
$this->router->class;

// call current method
$this->router->method;

USAGE

When loading a view from the controller instead of hardcoding your views names. you can do something like

$this->load->view("{$this->router->class}/{$this->router->method}");