php Function func_get_Args
Articles about php function func_get_args
The php func_get_args() function provides an easy way to get all the arguments that were passed into a given user-defined function. This can be useful in situations where the function is declared to take a fixed number of parameters but is called with a different number of parameters.
By default, php passes function arguments by value (the actual value of the argument is changed inside the function, but not outside) unless they are explicitly passed by reference. This allows for a lot of flexibility, but it also means that functions may be used in ways that would lead to a syntax error if they were written in another programming language.
For example, a function can use named parameters, but it cannot mix them with positional parameters. This is because the call-site cannot correctly infer the position of a parameter when it uses a name, but doesn't pass the same named parameters as its positional parameter. This is a case where a pattern like internal method chaining (a() calling b() directly) would suffer from Flaw: Class Does Too Much 1 because it combines two completely different responsibilities (formatting and processing the argument data).
The php func_get_args() can be used with a call-site that uses an associative array for its parameter list to allow a user-defined function to accept a variable-length argument list. However, be aware that if the associative array has non-numeric keys, this can cause a breaking change in future versions of PHP when they implement named parameters.