How does php implement dynamic parameter transfer ??? At last, this post was edited by ic2y _ in 2014-04-1717: 21: 01 and the code was simplified. & Lt ;? Php & nbsp; class & nbsp; Cache {public & nbsp; function & nbsp; get () {$ invoker & nbsp; how does deb php implement dynamic parameter transfer ???
This post was last edited by ic2y _ at 17:21:01
Paste the code first, and the code is simplified.
class Cache{
public function get()
{
$invoker= debug_backtrace();
$invoker_class= $invoker[1]["class"];
$invoker_function= $invoker[1]["function"]."_redirect";
$argus= func_get_args();
$invoker_class= str_replace("Action","", $invoker_class);
D($invoker_class)->$invoker_function($argus);
}
}
?>
Description:
The program is developed in ThinkPHP to forward the parameters received by the Cache get method to the specified method,
Last line: The D method is the singleton mode that comes with ThinkPHP. If the $ argus parameter is not added, it can be called normally.
Problem:
Now you want to pass parameters, such as get ("name", "age"), to D ($ invoker_class)-> $ invoker_function ("name", "age ").
Call_user_func seems to be okay, but it cannot be seen how to use it.
.
------ Solution --------------------
Call_user_func_array (array (D ($ invoker_class), $ invoker_function), $ argus );