Re: PHP 4.0 Bug #5490: class variables get mixed up
| From: | jalal | Date: | Sun, 09 Jul 2000 12:46:56 +0000 |
| Subject: | Re: PHP 4.0 Bug #5490: class variables get mixed up | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-23905@lists.php.net to get a copy of this message | ||
Hi Dietmar
You need to use
$this->A and $this->B to set and read the variables.
HTH jalal
On 10 Jul 2000 10:05:50 -0000, dietmar.kling@sam-net.de wrote:
>From: dietmar.kling@sam-net.de
>Operating system: linux 2.2.16
>PHP version: 4.0.1pl2
>PHP Bug Type: Misbehaving function
>Bug description: class variables get mixed up
>
><?php
>
>class bugtest
>{
> var $A = -1;
> var $B = -1;
>
> function setVarA($value)
> {
> $this->$A=$value;
> }
> function setVarB($value)
> {
> $this->$B=$value;
> }
>
> function getVarA()
> {
> return $this->$A;
> }
>
> function getVarB()
> {
> return $this->$B;
> }
>
>}
> echo "<BR>";
> echo "Current PHP version: ".phpversion();
> $bug = new bugtest;
> $bug->setVarA(13);
> $bug->setVarB(7);
> echo "<BR>";
> echo $bug->getVarA();
> echo "<BR>";
> echo $bug->getVarB();
>
>?>
>
>
>This is the output !! ( Where has "13" gone???")
>
>
>Current PHP version: 4.0.1pl2
>7
>7
>
>
>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
>For additional commands, e-mail: php-dev-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net