function foo() { $numargs = func_num_args(); //Number of arguments echo "The number of arguments is: $numargs<br />\n"; if ($numargs >= 2) { echo "The value of the second argument:" . func_get_arg(1) . "<br />\n"; } $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { echo "{$i}th parameter value: {$arg_list[$i]}<br />\n"; } } foo(1, 'd', 3,4);Output: The
number of parameters is: 4
The value of the second parameter: d The value of
the 0th parameter: 1
The value of the 1st parameter: d
The value of the 2nd parameter: 3
The value of the 3rd parameter: 4