|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-05-14 08:50 UTC] rcarmo at accao dot net
When calling a function with call_user_func_array, if one of the parameters is not set, the trailing hash values are assigned to the wrong parameters.
function test( $a, $b, $c ) {
echo "|$a:$b:$c|";
}
$aParams = array( "a" => 1, "c" => 3 );
call_user_func_array( "test", $aParams );
The output I get is
|1:3:|
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 13:00:01 2025 UTC |
Thanks. This would be extremely useful for XML-RPC/SOAP stuff with optional parameters (that have to be validated down at the actual function call level). Since there is no way to actually get a valid argument list on the function BEFORE doing call_user_func_array, I'm getting around it with stuff like this hideous kludge INSIDE the actual function: if( func_num_args() < 7 ) return new CFault( "400", "Client", "Incorrect number of method arguments", $php_errormsg );