CKTIS / PHP
call_user_func_array()
PHP 8 binds string keys to parameter names and integer keys by position in iteration order.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
call_user_func_array(callable $callback, array $args): mixedPHP 8 binds string keys to parameter names and integer keys by position in iteration order. An integer key after a named argument raises Error, as does assigning a parameter twice. The return value comes from the callback.
Signature
call_user_func_array(callable $callback, array $args): mixed
Example output
NW-42
Error
Examples
<?php
$format = fn($area, $number) => "$area-$number";
echo call_user_func_array($format, ["number"=>42,"area"=>"NW"]), "\n";
try { call_user_func_array($format, ["area"=>"NW", 42]); } catch (Error $e) { echo get_class($e); }
Result
NW-42 Error