ok im learning on how to make my own custom mvc system, so far i have created things like router and the controller.
example i have a controller profile class and an url http://www.helloworld.com/args1/args2/args3
class Profiles
{
function index($args1,$args2)
{
echo var_dump($args1,$args2);
}
}
heres are part of my router class that execute the method and the parms
if (is_callable(array($controller,$method))) {
call_user_func_array(array($controller, $method), $this->params);
}
so far no error but somehow i need to give a 404. if the $this->params is different then the count(params) in the method that i call at call_user_func_array(array($controller, $method),
$this->params);
ok what im thinking is if count get params not same as count params at the called class then 404,
lets say i can count my $this->params it gave me a 3. but how about the params in the called class ?
how can we count params in a called class by call_user_func_array?
Thanks for looking in
Adam Ramadhan
From what I know, there is no way of getting the parameter count for a method without using reflection. However, it’s pretty simple and would look something like this:
Will yield
Note that reflection always comes with a cost. However, the performance implications of this should not be noticable.