Menu Home

func_get_arg

osbo.com | PHP | Functions | func_get_arg

Return an item from the argument list

Syntax

func_get_arg ( int $arg_num ) : mixed

Parameters

arg_num

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

Return

Returns the specified argument, or FALSE on error.

Examples

1

<?

function myfunction() {
    $arg_num = 0;

    $return = func_get_arg($arg_num);

    echo $return;
}

myfunction("a");

?>
a

2

<?

function myfunction() {
    for ($i = 0; $i < func_num_args(); ++$i) {
        $arg_num = $i;
    
        $return = func_get_arg($arg_num);
    
        echo "$arg_num:$return\n";
    }
}

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

?>
0:a
1:b
2:c

PHP