|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
27 + 12 = ?
Subscribe to this entry?

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 22:01:29 2024 UTC