func_get_args retourne un tableau dont
les éléments correspondent aux éléments
de la liste d'arguments de la fonction.
func_get_args générera une
alerte si elle est appelée hors d'une fonction.
<?php function foo() { $numargs = func_num_args(); echo "Nombre d'arguments: $numargs<br>\n"; if ($numargs >= 2) { echo "Le second argument est: " . func_get_arg (1) . "<br>\n"; } $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { echo "L'argument $i est: " . $arg_list[$i] . "<br>\n"; } } foo(1, 2, 3); ?>
func_get_arg peut être utilisé
conjointement à func_num_args et
func_get_args pour permettre aux fonctions
utilisateurs d'accepter un nombre variable d'arguments.