func_get_arg

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

call_user_func

call_user_func_array

forward_static_call

forward_static_call_array

func_get_args

func_num_args

function_exists

get_defined_functions

register_shutdown_function

register_tick_function

unregister_tick_function

PHP

Home Menu