php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60510 Parameters are
Submitted: 2011-12-13 13:32 UTC Modified: 2011-12-16 16:03 UTC
From: pawel dot chmiel at op dot pl Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.3.8 OS: Windows 7 x64
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: pawel dot chmiel at op dot pl
New email:
PHP Version: OS:

 

 [2011-12-13 13:32 UTC] pawel dot chmiel at op dot pl
Description:
------------
---
From manual page: http://www.php.net/function.call-user-func#refsect1-function.call-user-func-parameters
---
Please change:

Note that the parameters for call_user_func() are not passed by reference. 

to

Note that the parameters for call_user_func() are passed by reference. 

Test script:
---------------
<?php
error_reporting(E_ALL);
class A {
 var $oObject;
    
 public function ChangeMe( $oObject ) {
  $oObject->name = 'wrong';
 }
}

class Object{
 var $name;
 public function __construct() {
     $this->name = 'Good';
 }
}

$test=new Object();
$a = new A();

call_user_func( array( $a, 'ChangeMe' ), $test );
echo "The PHP documentation for function call_user_func is: " .$test->name;

?>

Expected result:
----------------
The PHP documentation for function call_user_func is: Good

Actual result:
--------------
The PHP documentation for function call_user_func is: wrong

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-16 16:03 UTC] nikic@php.net
-Status: Open +Status: Bogus
 [2011-12-16 16:03 UTC] nikic@php.net
The parameters are not actually passed by reference. What you are experiencing is that objects show *reference-like* behavior when *passed by value*. But this is independent of call_user_func.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC