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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 06:01:31 2024 UTC