#25167 [Opn->Bgs]: Variable get overwritten inside class

From: Date: Wed, 20 Aug 2003 08:19:15 +0000
Subject: #25167 [Opn->Bgs]: Variable get overwritten inside class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-46288@lists.php.net to get a copy of this message
ID: 25167 Updated by: sniper@php.net Reported By: bakkerl at lamp dot xs4all dot nl -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: RedHat 9 PHP Version: 4.3.2 New Comment: If your script didn't have all those errors, it would work just fine..(hint: $this->a) Previous Comments: ------------------------------------------------------------------------ [2003-08-20 02:59:05] bakkerl at lamp dot xs4all dot nl Description: ------------ A class which contains more than 1 variable, all varible gets the same values. The all get the value of the last value assinging. Reproduce code: --------------- <?php class test { var $a; var $b; function test() { $this->$a = "Hello"; $this->$b = "World!"; } function showWorld() { echo $this->$a." ".$this->$b; } } ?> Expected result: ---------------- After calling showWorld() i would expect to see: "Hello World!". Actual result: -------------- After calling showWorld() i got: "World! World!" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25167&edit=1

« previous php.bugs (#46288) next »