func_get_args
Description
The func_get_args of Function Handling for PHP returns an array comprising a function's argument list.
Syntax
func_get_args(): array
Return
Returns an array in which each element is a copy of the corresponding member of the current user-defined function's argument list.
Examples
1 · void
<?
function myfunction()
{
$return = func_get_args();
print_r($return);
}
myfunction("a", "b", "c");
myfunction("d", "e", "f", "g");
myfunction("h", "i");
Array
(
[0] => a
[1] => b
[2] => c
)
Array
(
[0] => d
[1] => e
[2] => f
[3] => g
)
Array
(
[0] => h
[1] => i
)
2 · for
<?
function myfunction()
{
$number = func_num_args();
$return = func_get_args();
for($i = 0; $i < $number; ++$i)
{
echo $i . ": " . $return[$i] . PHP_EOL;
}
echo PHP_EOL;
}
myfunction("a", "b", "c");
myfunction("d", "e", "f", "g");
myfunction("h", "i");
0: a 1: b 2: c 0: d 1: e 2: f 3: g 0: h 1: i