Revision: 31454
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 6, 2010 19:49 by silviud
Initial Code
function foo() { $numargs = func_num_args(); // number of arguments if ($numargs >= 2) { echo "Second argument is: " . func_get_arg(1) . "<br />\n"; } $arg_list = func_get_args(); // all arguments as an array for ($i = 0; $i < $numargs; $i++) { echo "Argument $i is: " . $arg_list[$i] . "<br />\n"; } } foo(1, 2, 3); foo(1, 2, 3, 4, 5);
Initial URL
Initial Description
allows for variable length arguments - something similar as python func(*args, **kw)
Initial Title
php variable length arguments
Initial Tags
php
Initial Language
PHP