Bug #15871: variable variables need { } to work with classes

From: Date: Tue, 05 Mar 2002 12:13:35 +0000
Subject: Bug #15871: variable variables need { } to work with classes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-1670@lists.php.net to get a copy of this message
From: greg@mtechsolutions.ca Operating system: linux PHP version: 4.1.2 PHP Bug Type: Variables related Bug description: variable variables need { } to work with classes When using a variable variable in a class, $$this->varname does not work, ${$this->varname} must be used. Here is a simple script to show this in action. Put the {} in and it will work: <? $id = "yes"; class testClass { var $varname; function testClass($varname) { $this->varname = $varname; } function foo() { global $$this->varname; echo "$".$this->varname." is ".$$this->varname; } } $test = new testClass("id"); $test->foo(); ?> -- Edit bug report at http://bugs.php.net/?id=15871&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=15871&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=15871&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=15871&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=15871&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=15871&r=support Expected behavior: http://bugs.php.net/fix.php?id=15871&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=15871&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=15871&r=submittedtwice

« previous php.bugs (#1670) next »