Warning: file_put_contents(): Only -1 of 53 bytes written, possibly out of free disk space in /var/www/html/index.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 25
func_get_args Podręcznik PHP Poprzedni Następny (PHP 4, 5) func_get_args -- Returns an array comprising a function's argument list Opis ( void ) Gets of the list. This function may...
Forum und email
func_get_args

func_get_args

(PHP 4, PHP 5)

func_get_args -- Returns an array comprising a function's argument list

Opis

array func_get_args ( void )

Gets an array of the function's argument list.

This function may be used in conjunction with func_get_arg() and func_num_args() to allow user-defined functions to accept variable-length argument lists.

Zwracane wartości

Returns an array in which each element is a copy of the corresponding member of the current user-defined function's argument list.

Błędy/Wyjątki

Generates a warning if called from outside of a user-defined function.

Przykłady

Przykład 1. func_get_args() example

<?php
function foo()
{
    
$numargs = func_num_args();
    echo
"Number of arguments: $numargs<br />\n";
    if (
$numargs >= 2) {
        echo
"Second argument is: " . func_get_arg(1) . "<br />\n";
    }
    
$arg_list = func_get_args();
    for (
$i = 0; $i < $numargs; $i++) {
        echo
"Argument $i is: " . $arg_list[$i] . "<br />\n";
    }
}

foo(1, 2, 3);
?>

Notatki

Notatka: Jako że działanie tej funcji zależy od aktualnego zasięgu, nie może ona być użyta jako parametr funkcji. Jeśli konieczne jest przekazanie tej wartości, należy przypisać wynik działania tej funkcji do zmiennej, a następnie, jako parametr, przekazać tą zmienną.

Notatka: This function returns a copy of the passed arguments only, and does not account for default (non-passed) arguments.