#22443 [Opn->Bgs]: Reference problem inside constructor
| From: | moriyoshi@php.net | Date: | Thu, 06 Mar 2003 21:24:56 +0000 |
| Subject: | #22443 [Opn->Bgs]: Reference problem inside constructor | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-34991@lists.php.net to get a copy of this message | ||
ID: 22443
Updated by: moriyoshi@php.net
Reported By: oracle16 at freemail dot hu
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows
PHP Version: 4.3.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
[HINT] $a = &new A();
Previous Comments:
------------------------------------------------------------------------
[2003-02-26 11:27:16] oracle16 at freemail dot hu
I have a problem when using two-way references.
The simplest case I could dig out:
<pre>
class B
{
var $a;
function B(& $a)
{
$this->a = & $a;
}
}
class A
{
var $b;
function A()
{
$this->b = & new B($this);
}
}
$a = new A();
$a->x = "ax";
print $a->b->a->x;
<pre>
I think this should print out "ax". However it doesn't.
If I add the following line after constructing $a:
$a->b->a = &$a;
then it works, it prints out "ax".
Or, if I define A like this:
<pre>
class A
{
var $b;
function A()
{
$this->b = & new B($this);
}
function setBsA()
{
$this->b->a = & $this;
}
}
</pre>
and call setBsA() after contructing, it still works.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22443&edit=1