Returns a variable argument from an SPL routine.
GETARGV(n)
n |
- |
An integer, the index of the variable argument. |
The value of the variable input argument.
vmax(2, 3, 1, 5, 4)
returns 5, the maximum of the input arguments.
ARGV in the argument list of an SPL routine specifies a variable number of input arguments. The above routine returns the maximum of two or more expressions.
ARGC returns the total number of input arguments and GETARGV obtains a particular variable argument.
The input for GETARGV specifies the index of the variable argument so getargv(2) refers to the second variable argument. Consider:
fact2(2, 3, 4, 5, 6, 7) == 5040
FACT2 is an SPL routine that accepts 2 specified arguments and any number of variable arguments. The result is the product of all the arguments. The expression getargv(i) returns the ith variable argument.