PHP 4.0 Bug #7659: Class variables get confused

From: Date: Mon, 06 Nov 2000 11:14:51 +0000
Subject: PHP 4.0 Bug #7659: Class variables get confused
Groups: php.dev 
Request: Send a blank email to php-dev+get-37247@lists.php.net to get a copy of this message
From: awilkins@hmc.edu Operating system: RedHat Linux 6.2 PHP version: 4.0 Latest CVS (06/11/2000) PHP Bug Type: Scripting Engine problem Bug description: Class variables get confused 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 -- Edit Bug report at: http://bugs.php.net/?id=7659&edit=1

« previous php.dev (#37247) next »