Reputation: 132
i am trying to call a function in a class using this line of code..
$controller = new $controller;
$method = 'first';
call_user_func_array([$controller,$method],$params);
the problem is not every function have a parameter. but when the $params method is available and the called function is not having any parameters.
and i want to have an action when th
so my question is, how to get a number of parameter on a function before a caling a function in a class?
sory for my bad english, i hope you got the point.. thanks..
Upvotes: 0
Views: 55
Reputation: 2447
You can use reflection to look at the function,
https://www.php.net/manual/en/class.reflectionfunction.php
There's an example of how to use it in there. To expand on this a little more, you're calling a class method. You can get the class first and then get to the method that way, https://www.php.net/manual/en/class.reflectionclass.php
Upvotes: 2