Variable Parameter Counts : func_num_args « Functions « PHP






Variable Parameter Counts

 
function some_func($a, $b) {
            for ($i = 0; $i < func_num_args( ); ++$i) {
                    $param = func_get_arg($i);
                    echo "Received parameter $param.\n";
            }
    }

    function some_other_func($a, $b) {
            $param = func_get_args( );
            $param = join(", ", $param);
            echo "Received parameters: $param.\n";
    }

    some_func(1,2,3,4,5,6,7,8);
    some_other_func(1,2,3,4,5,6,7,8);
  
  








Related examples in the same category

1.Accessing function parameters without using the argument list
2.Get parameter count from func_num_args ()