php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13476 probleme when using &$this in a constructor
Submitted: 2001-09-28 06:16 UTC Modified: 2002-12-06 19:32 UTC
From: e dot sobole at webshaker dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.6 OS: linux Debian 2.2
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: e dot sobole at webshaker dot net
New email:
PHP Version: OS:

 

 [2001-09-28 06:16 UTC] e dot sobole at webshaker dot net
When I'm triing to use a reference on $this into the constructor of a object, it's a copy of the reference which is passed.

have a look to this sample.

class A
{
 var $value;
 var $pB;

 function A()
 {
  $this->Value = 100;
 }
}

class B
{
 var $value;
 function B(&$aa)
 {
  $this->value = 200;
  $aa->pB = &$this;
 }
}

$aa = new A();
$bb = new B($aa);
$bb->value = 50;

echo var_dump($aa);

there is no 50 in the repr?sentation of the var_dump function.

I've looked in the doc if this limitation is sp?cified, but NO!

Etienne

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-14 14:07 UTC] yohgaki@php.net
To me, it is explained in document at least now. Although it may not be a clear for everyone. This is known issue for a long time.
 [2001-12-14 14:08 UTC] yohgaki@php.net
Let's set to Suspended.
 [2002-12-06 19:32 UTC] sniper@php.net
not a bug -> bogus.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 09:01:28 2025 UTC