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_dieexits after a call debugthat takes a variable number of arguments.

Thus, arguments passed debug_dieas such are intended only for debugand should simply be redirected. How can this be done in a method debug_die?

+3
source share
1 answer
function debug_die() {
    call_user_func_array("debug", func_get_args());
    die;
}
+4
source

Source: https://habr.com/ru/post/1774757/


All Articles