Codeigniter routing behavior with the controllers magic method __call-Collection of common programming errors

In CodeIgniter, there is _remap. So if you go to

XYZ.com/Class/UndefinedMethod/param1/param2

then _remap will be called (actually _remap will always be called, so we need to make sure that methods that do exist are called correctly).

function _remap($method, $params=array()){
    $funcs = get_class_methods($this);
    if(in_array($method, $funcs)){ // We are trying to go to a method in this class
        return call_user_func_array(array($this, $method), $params);
    }
    // else do something else
}

Originally posted 2013-11-09 21:09:13.