PHP 4.0 Bug #6193 Updated: new object makes a shallow copy
| From: | Bug Database | Date: | Wed, 16 Aug 2000 11:48:49 +0000 |
| Subject: | PHP 4.0 Bug #6193 Updated: new object makes a shallow copy | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-29115@lists.php.net to get a copy of this message | ||
ID: 6193
Updated by: waldschrott
Reported By: Heinz@chanet.de
Status: Analyzed
Bug Type: Scripting Engine problem
Assigned To:
Comments:
Right, that´s two bugs here... the only proper way I know of to workaround this is to reference
them outside, like this:
$x = new A();
$c_x = &$x;
1) neither copying nor referencing works in this case inside the constructor, I remember this as a
possibly known issue...
2) re-referencing does not work... I´ve moved that linking process to another method (not
constructor)
- both referencing AND copying works *inside* CTest->Reg, but zend fails to recognize that $reg
is already a reference, thus it is not visible outside
I think even this is a known issue, not sure
$register_object;
class CTest {
var $v=9;
function CTest() { }
function reg(&$reg) {
$reg=$this;
var_dump($reg); }
}
$myobj= new CTest();
$myobj->reg($register_object);
var_dump($register_object);
$myobj->v= 1;
$register_object->v= 2;
echo 'both should be equal: ', $myobj->v, ' ',
$register_object->v;
Full Bug description available at: http://bugs.php.net/?id=6193