HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

func_num_args

Description

The func_num_args of Function Handling for PHP returns the number of arguments passed to the function.

Syntax

func_num_args(): int

Return

Returns the number of arguments passed into the current user-defined function.

Examples

1 · void

<?

function myfunction()
{
    $return = func_num_args();
    
    echo $return . PHP_EOL;
}

myfunction("a", "b", "c");
myfunction("d", "e", "f", "g");
myfunction("h", "i");
3
4
2

2 · for

<?

function myfunction()
{
    $return = func_num_args();
    $array = func_get_args();

    for($i = 0; $i < $return; ++$i)
    {
        echo $i . ": " . $array[$i] . PHP_EOL;
    }

    echo PHP_EOL;
}

myfunction("a", "b", "c");
myfunction("d", "e", "f", "g");
myfunction("h", "i");
0: a
1: b
2: c

0: d
1: e
2: f
3: g

0: h
1: i