php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51179 call_user_func() should take parameters by reference
Submitted: 2010-03-02 02:19 UTC Modified: 2010-03-05 13:26 UTC
From: info at fedushin dot ru Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.13 OS:
Private report: No CVE-ID: None
 [2010-03-02 02:19 UTC] info at fedushin dot ru
Description:
------------
Currently it's impossible to pass variable by reference to user callback through call_user_func().
There's plenty of complaints about it on the Web.
Such missing possibility would be very useful.

As said in Bug #17309, the situation is not a bug because call_user_func() takes its parameters by value.
Suggestion is to change call_user_func() signature & make it take 2nd & following parameters by reference.

Test script:
---------------
<?php
function foo(&$arg) {
  $arg++;
}
$var = 0;
call_user_func("foo", $var);
echo $var; // echoes 0 instead of 1.
?>

Expected result:
----------------
1

Actual result:
--------------
0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-05 13:26 UTC] jani@php.net
-Status: Open +Status: Bogus
 [2010-03-05 13:26 UTC] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

The bug db is full of these reports. Next time, search first.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 19:01:30 2024 UTC