Variable length Argument Function
func_num_args()
Returns the number of arguments passed to the function
Syntax : int func_num_args ( void )
Returns the number of arguments passed into the current user-defined function. func_num_args() will generate a warning if called from outside of a user-defined function.
func_get_arg()
-- Return an item from the argument list
Syntax : mixed func_get_arg ( int arg_num)
Returns the argument which is at the arg_num'th offset into a user-defined function's argument list. Function arguments are counted starting from zero. func_get_arg() will generate a warning if called from outside of a function definition.
If arg_num is greater than the number of arguments actually passed, a warning will be generated and func_get_arg() will return FALSE.
= 2) { echo "Second argument is: " . func_get_arg(1) . "
\n"; }} foo (1, 2, 3);?>
func_get_args()
-- Returns an array comprising a function's argument list
Syntax : array func_get_args ( void )
Returns an array in which each element is the corresponding member of the current user-defined function's argument list. func_get_args() will generate a warning if called from outside of a function definition
= 2) { echo "Second argument is: " . func_get_arg(1) . "
\n"; } $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { echo "Argument $i is: " . $arg_list[$i] . "
\n"; }} foo(1, 2, 3);?>
Post a Comment