ID: 11092
Updated by: sbergmann
Status: Open
Bug Type: Scripting Engine problem
Operating system: 
PHP Version: 4.0.5
Assigned To: 

Just noticed: It works as expected when I replace

  $a = $b->add_a();


  $a =& $b->add_a();

But this is not the syntax I was thinking of for my class. The user, which probably 
doesn't know of the class's internals, now has always use the =& assignment operator. 
This is definetly error-prone.

Previous Comments:

[2001-05-24 13:04:25] [EMAIL PROTECTED]
There seems to be a problem with objects returned from class methods by reference:

class a {
  var $data;

  function add_data($data) {
    $this->data[] = $data;

class b {
  var $a;

  function &add_a() {
    $this->a = new a;
    return $this->a;

  function dump() {

$b = new b;
$a = $b->add_a();
$a->add_data('test');    // works not
$b->a->add_data('test'); // works


ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to