Argument Forwarding in PHP
Consider the following functions:
function debug() {
$args = func_get_args();
// process $args
}
function debug_die() {
// call debug() with the passed arguments
die;
}
The method debug_die
exits after calling debug
that takes a variable number of arguments. 开发者_如何学运维
So the arguments passed to debug_die
as such are meant for debug
only and just have to be forwarded. How can this be done in the debug_die
method?
function debug_die() {
call_user_func_array("debug", func_get_args());
die;
}
精彩评论