|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17207 call_user_func_array does not bind array keys to params
Submitted: 2002-05-14 08:50 UTC Modified: 2014-12-30 10:41 UTC
From: rcarmo at accao dot net Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 4.1.2 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: rcarmo at accao dot net
New email:
PHP Version: OS:


 [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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-14 08:53 UTC]
This is not supposed to work at all, I'm making this a feature request.

 [2002-05-14 09:29 UTC] rcarmo at accao dot net
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 );
 [2014-04-16 16:38 UTC]
This is similar to the RFC for named parameters:
 [2014-04-28 14:16 UTC]
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: Arrays related -Operating System: Any +Operating System: Irrelevant
 [2014-04-28 14:16 UTC]
Is this something you are still interested in seeing?
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 01:01:27 2023 UTC