call_user_func_array()
's PHP manual's examples can only make me more confused with those foo
and bar
variables!
Anyway, please consider the _remap
and ComplexFunction
below:
class MyClass extends CI_Controller
{
public function _remap($method, $params = array())
{
if (method_exists($this, $method))
{
return call_user_func_array(array($this, $method), $params);
}
}
public function ComplexFunction($param1, $param2, $param3, $param4)
{
// process
return 'done';
}
}
Now will this piece of code work correctly?
$params = array(
'param1' => '1',
'param2' => '2',
'param3' => '3',
'param4' => '4'
);
$myObject = new MyClass();
$output = call_user_func_array(array($myObject, 'ComplexFunction'), $params);
echo $output;
- Will the
$output
bedone
? - Is that a reliable method to use in codeigniter's
_remap()
function?