#11748 [Com]: setting reference to $this in constructor.
| From: | chat-room852 at hotmail dot com | Date: | Tue, 20 Jul 2004 15:07:55 +0000 |
| Subject: | #11748 [Com]: setting reference to $this in constructor. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-62998@lists.php.net to get a copy of this message | ||
ID: 11748
Comment by: chat-room852 at hotmail dot com
Reported By: zork at pablosoft dot com dot pl
Status: Bogus
Bug Type: Class/Object related
Operating System: Linux 2.2.x
PHP Version: 4.0 Latest CVS (2001-06-27)
New Comment:
<a href=http://yquickbukkake-blowp.da.ru>room
chat</a>
Previous Comments:
------------------------------------------------------------------------
[2001-10-21 19:29:40] sniper@php.net
only one bug report per bug. (Other one is: #11768)
------------------------------------------------------------------------
[2001-06-27 12:04:54] zork at pablosoft dot com dot pl
When I want to set reference to $this object gets copied.
In this example $ui_handler contains copy of object $test.
$ui_handler -> data is not reference to $test,
<?
class CUI_element {
var $value;
function CUI_element($value) {
global $ui_handler;
$this -> value = $value;
$ui_handler -> register($this);
}
}
class CUI_handler {
var $data;
function CUI_handler() {
$this -> data = false;
}
function register(&$element) {
$this -> data = &$element;
}
};
$ui_handler = new CUI_Handler();
$test = new CUI_Element("test");
$test -> value = "changed";
var_dump($ui_handler -> data); print "<br>";
var_dump($test); print "<br>";
?>
My output:
object(cui_element)(1) { ["value"]=> string(4) "test" }
object(cui_element)(1) { ["value"]=> string(7) "changed" }
Working url: http://biuro.pablosoft.com.pl/~zork/ref/tests.php
regards
Zork.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=11748&edit=1