php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25526 call_user_func_array corrupts the passed array
Submitted: 2003-09-13 11:57 UTC Modified: 2003-09-14 20:14 UTC
From: sprice at wisc dot edu Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.3 OS: OS X 10.2.6
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sprice at wisc dot edu
New email:
PHP Version: OS:

 

 [2003-09-13 11:57 UTC] sprice at wisc dot edu
Description:
------------
call_user_func_array seems to corrupt the array that is 
passed to the user function through it.

If an array of two strings are passed, and you try to 
print $strings[0] you get the first letter of the first 
element. If you try to print $strings[1] you get the 
2nd letter of the first element.

Reproduce code:
---------------
<?php
function test($testing){
	echo $testing[1];
}

$array = array('im testing', 'hello?');

call_user_func_array('test', $array);
echo "\n";
echo $array[1];
?>

Expected result:
----------------
hello?
hello?

Actual result:
--------------
m
hello?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-14 20:14 UTC] iliaa@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

Re-read the documentation for call_user_func_array() more closely. Your test() should take 2 parameters, the 1st is the variable name and 2nd is the actual array.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 02:01:27 2024 UTC