Function

PHP Function

func_get_args()

func_get_args(): array

Returns an array comprising a function’s argument list

function MyFunction() {
  $function_arguments = func_get_args();
    print_r($function_arguments);
}


MyFunction('a', 'b', 'c', 1, 2, 3);
// Array
// (
//     [0] => a
//     [1] => b
//     [2] => c
//     [3] => 1
//     [4] => 2
//     [5] => 3
// )

func_get_arg()

func_get_arg(int $position): mixed

Return an item from the argument list

function MyFunction() {
    $function_argument = func_get_arg(0);
    print_r($function_argument);     // a
}


MyFunction('a', 'b', 'c', 1, 2, 3);  // a

func_num_args()

func_num_args(): int

Returns the number of arguments passed to the function

function MyFunction() {
    $function_arguments_nums = func_num_args();
    var_dump($function_arguments_nums);       // 6
}

MyFunction('a', 'b', 'c', 1, 2, 3);

call_user_func()

call_user_func(callable $callback, mixed ...$args): mixed

Call the callback given by the first parameter

function MyFunction(string $name, int $age) {
    print_r($name); // KJ
    print_r($age);  // 18
}

call_user_func('MyFunction', 'KJ', 18);

call_user_func_array()

call_user_func_array(callable $callback, array $args): mixed

function MyFunction(string $name, int $age) {
    print_r($name); // KJ
    print_r($age);  // 18
}

call_user_func_array('MyFunction', ['KJ', 18]);

String

PHP String Function

Array

PHP Array Function

Math

PHP Math Function

Filter

PHP Filter Function

Class

PHP Class Function

Sort

PHP Sort Function

File

PHP File Function

Time

PHP Time Function

Variable Handling

PHP Variable Handling Function

Http

PHP Http Function

System

PHP System Function

Generator

PHP Generator Function