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

func_get_arg

Description

The func_get_arg of Function Handling for PHP return an item from the argument list.

Syntax

func_get_arg(int $position): mixed

Parameters

position

The argument offset. Function arguments are counted starting from zero.

Return

Returns the specified argument, or false on error.

Examples

1

<?

function myfunction()
{
    $position = 1;

    $return = func_get_arg($position);

    echo $return;
}

myfunction("a", "b", "c");

?>
b

2

<?

function myfunction()
{
    for($i = 0; $i < func_num_args(); ++$i)
    {
        $position = $i;

        $return = func_get_arg($position);

        echo "$position: $return\n";
    }
    echo "\n";
}

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

HomeMenu