PHP 4.0 Bug #7659 Updated: Class variables get confused
| From: | stas@php.net | Date: | Mon, 06 Nov 2000 11:25:21 +0000 |
| Subject: | PHP 4.0 Bug #7659 Updated: Class variables get confused | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-37248@lists.php.net to get a copy of this message | ||
ID: 7659
Updated by: stas
Reported By: awilkins@hmc.edu
Status: Closed
Bug Type: Scripting Engine problem
Assigned To:
Comments:
Please read the manual. Syntax is $obj->var, not $obj->$var.
Previous Comments:
---------------------------------------------------------------------------
[2000-11-06 06:14:51] awilkins@hmc.edu
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
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7659