From:             jsabater at linuxsilo dot net
Operating system: Linux
PHP version:      4.3.3
PHP Bug Type:     Documentation problem
Bug description:  Right way to pass parameters to call_user_func_array 

Description:
------------
When calling a defined function like this:

call_user_func_array ('myfunc', $myarray);

The $myarray array only contains the first value, but not the whole array.
For instance:

function myfunc ($myarray)
{
  if (is_array($myarray)) print("It's an array");
  else print ("It's not an array");
}

call_user_func_array ('myfunc', array ("first", "second", "third"));

Then you would receive the message "It's not an array". If you print_r the
array, then you would only get "first".

Then, if you change the call to this:

call_user_func_array ('myfunc', array (array ("first", "second",
"third")));

It works as expected. So, the documentation available at
http://es.php.net/manual/en/function.call-user-func-array.php seems to be
wrong.

Thanks for your time. Hope this helps.

Reproduce code:
---------------
function myfunc ($myarray)
{
  if (is_array($myarray)) print("It's an array");
  else print ("It's not an array");
}

call_user_func_array ('myfunc', array ("first", "second", "third"));

Expected result:
----------------
It's an array

Actual result:
--------------
It's not an array

-- 
Edit bug report at http://bugs.php.net/?id=26585&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26585&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26585&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26585&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26585&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26585&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26585&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26585&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26585&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26585&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26585&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26585&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26585&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26585&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26585&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26585&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26585&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26585&r=float

Reply via email to