Content deleted Content added
+ var'length arg lists in PHP, +optional args with default values |
m subsection for optional args |
||
Line 7:
Variadic functions can expose type-safety problems in some languages. For instance, C's <TT>printf</TT>, if used uncautiously, can give rise to a class of security holes known as [[format string attack]]s. The attack is possible because the language support for variadic functions is not [[type safety|type-safe]]; it permits the function to attempt to pop more arguments off the stack than were placed there -- corrupting the stack and leading to unexpected behavior.
In [[PHP]], [http://php.net/functions_arguments variable-length argument lists] are natively supported (without security risk) since version 4; dedicated functions (func_num_args, func_get_arg, func_get_args) allow the programmer to determine the number and values of unspecified arguments.
=== Optional arguments with default values ===
Besides the concept of a ''completely arbitrary number'' of arguments,▼
▲Besides the concept of a ''completely arbitrary number'' of arguments as discussed above,
the declaration of '''[[default value]]s''' for ''some'' of the ''specified arguments'' is another concept allowing to call a function with variable number of arguments.
Several [[typed language]]s implement this, and can in some cases associate the arguments to the corresponding variables in view of their type, even if they are given at [[call-time]] in an order differing from the declaration.
|