php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25419 Call-time pass-by-reference has been deprecated but without it it's impossible t
Submitted: 2003-09-07 14:51 UTC Modified: 2003-09-07 17:15 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:0 of 1 (0.0%)
From: roland at inkoeln dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4.3.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 + 45 = ?
Subscribe to this entry?

 
 [2003-09-07 14:51 UTC] roland at inkoeln dot com
Description:
------------
You *must* use Call-time pass-by-reference to pass a    
object-reference when using call_user_function. 
  
In the example changeA() is declared to use passing 
by reference but it still doesn't work. I think  
call_user_function should either try to discover if it's 
passing by reference at runtime or just pass always by 
reference.  
  
   
      

Reproduce code:
---------------
<?php

class A {
var $_id = 'A';

function printID() {
  print "A::id=[".$this->_id."]\n";
}

function remote(&$obj_ref, $obj_method) {
  call_user_func(array(&$obj_ref, $obj_method), $this);
  // this on works:
  // call_user_func(array(&$obj_ref, $obj_method),&$this);
}
}

class B {
function changeA(&$obj) {
  $obj->_id = 'B';
  $obj->printID();
}
}

$a = new A();
$b = new B();
$a->printID();
$a->remote($b, 'changeA');
$a->printID();

?>

Expected result:
----------------
A::id=[A]  
A::id=[B]  
A::id=[B] 
 
  
   

Actual result:
--------------
A::id=[A]  
A::id=[B]  
A::id=[A] 
  

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-07 17:15 UTC] sniper@php.net
Fixed in PHP 5 (ZE2), won't fix in PHP 4.

 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Aug 11 05:05:45 2022 UTC