|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-02-13 10:31 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
Description: ------------ Using =&, it is possible to modify $this with the constructor. This shouldn't be allowed, just like for $tmp = $this; Reproduce code: --------------- <?php class B { function B() { } } class A { function A() { $tmp =& $this; var_dump($this); // outputs : object(A) $tmp = new B(); var_dump($this); // outputs : object(B) } } $a = new A(); var_dump($a); // outputs : object(A) ?> Expected result: ---------------- object(A)#1 (0) { } object(A)#2 (0) { } object(A)#1 (0) { } // current result : object(A)#1 (0) { } object(B)#2 (0) { } object(A)#1 (0) { }