Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Variable-length Argument List In PHP

DZone's Guide to

Variable-length Argument List In PHP

·
Free Resource
See the document for 
func_num_args(), func_get_arg(), and func_get_args().

function foo()
{
   $numargs = func_num_args();
   echo "Number of arguments: $numargs
\n"; if ($numargs >= 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);
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}