php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65428 call_user_func_array can't accept params correctly
Submitted: 2013-08-09 16:41 UTC Modified: 2013-08-09 17:14 UTC
From: 1suming at sina dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.4.17 OS: windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: 1suming at sina dot com
New email:
PHP Version: OS:

 

 [2013-08-09 16:41 UTC] 1suming at sina dot com
Description:
------------
---
From manual page: http://www.php.net/function.call-user-func-array#refsect1-
function.call-user-func-array-description
---
class Foo
{
	 
	public function printArray(array $arr)
	{
		var_dump($arr);
	}
}

 
$foo1=new Foo();
call_user_func_array(array($foo1,'printArray'),array(1,2));
when I run,the result is
Catchable fatal error: Argument 1 passed to foo::printArray() must be of the 
type array, integer 

but when i change  call_user_func_array to call_user_func,it's ok.
Don't call_user_func_array   accept params?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-09 17:14 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2013-08-09 17:14 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The second argument to call_user_func_array() is an array of the arguments to 
pass. Not an entire argument by itself. That's the whole point of having this 
function alongside call_user_func().
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 17:01:29 2025 UTC