|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-11-06 06:25 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 11 11:00:01 2026 UTC |
When this script is run: <?php class Three { var $one, $two; function Three($a, $b) { echo "a is $a; b is $b<br>\n"; $this->$one = $a; echo "one is " . $this->$one . "; two is " . $this->$two . "<br>\n"; $this->$two = $b; echo "one is " . $this->$one . "; two is " . $this->$two . "<br>\n"; } } $three = new Three(1, 2); ?> the results it produces are: a is 1; b is 2 one is 1; two is 1 one is 2; two is 2 For some reason, it appears as if the two separate variables $one and $two are pointing at the same thing. This doesn't appear to be a problem that is specific to the constructor, as it happens even if the function involved is only a normal function. It also occurs if the variables are modified outside of the class. I also found this bug in 4.0.3pl1, but have not tried any earlier version. The only module I compiled PHP with was pgsql, if it matters. Alex Wilkins