Doc #60510 [Opn->Bgs]: Parameters are
| From: | nikic@php.net | Date: | Fri, 16 Dec 2011 16:03:45 +0000 |
| Subject: | Doc #60510 [Opn->Bgs]: Parameters are | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7664@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60510&edit=1
ID: 60510
Updated by: nikic@php.net
Reported by: pawel dot chmiel at op dot pl
Summary: Parameters are
-Status: Open
+Status: Bogus
Type: Documentation Problem
Package: Documentation problem
Operating System: Windows 7 x64
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2011-12-13 13:32:11] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60510&edit=1