Codeigniter how to get all/specific method in current controller

class, codeigniter, controller, methods, php

Solution

you can use native php to get the class methods

get_class_methods($this);

the $this is the controller being called

Sample only

class user extends CI_Controller {

    public function __construct() {

                #-------------------------------
                # constructor
                #-------------------------------

                parent::__construct();

                var_dump(get_class_methods($this));

            }

}

read on the documentation

http://php.net/manual/en/function.get-class-methods.php

Problem

I know this code: ``` $this->router->fetch_class(); // get current controller name $this->router->fetch_method(); // get current method name ``` What I want to do is get all the method available in current controller or specific controller. Anyone had the same experience? Thank You. SOLUTIONS I create helper to list all method in the specific controller ``` function list_this_controllers_method_except($controller, $except = array()) { $methods = array(); foreach(get_class_methods($controller) as $method) { if (!in_array($method, $except)) { $methods[] = $method; } } return $methods; } ```

Original source