note 125953 added to function.call-user-func-array

From: Date: Tue, 23 Mar 2021 20:01:47 +0000
Subject: note 125953 added to function.call-user-func-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-219283@lists.php.net to get a copy of this message
Using PHP 8, call_user_func_array call callback function using named arguments if an array with keys is passed to $args parameter, if the array used has only values, arguments are passed positionally. <?php function test(string $param1, string $param2): void { echo $param1.' '.$param2; } $args = ['hello', 'world']; //hello world call_user_func_array('test', $args); $args = ['param2' => 'world', 'param1' => 'hello']; //hello world call_user_func_array('test', $args); $args = ['unknown_param' => 'hello', 'param2' => 'world']; //Fatal error: Uncaught Error: Unknown named parameter $unknown_param call_user_func_array('test', $args); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.247 (proxied: 2.236.98.148) ---- Manual Page -- http://php.net/manual/en/function.call-user-func-array.php Edit -- https://master.php.net/note/edit/125953 Del: integrated -- https://master.php.net/note/delete/125953/integrated Del: useless -- https://master.php.net/note/delete/125953/useless Del: bad code -- https://master.php.net/note/delete/125953/bad+code Del: spam -- https://master.php.net/note/delete/125953/spam Del: non-english -- https://master.php.net/note/delete/125953/non-english Del: in docs -- https://master.php.net/note/delete/125953/in+docs Del: other reasons-- https://master.php.net/note/delete/125953 Reject -- https://master.php.net/note/reject/125953 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#219283) next »