note 25023 modified in language.variables.variable by danbrown

From: Date: Wed, 24 Jun 2009 16:59:10 +0000
Subject: note 25023 modified in language.variables.variable by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157411@lists.php.net to get a copy of this message
I found another undocumented/cool feature: variable member variables in classes. It's pretty easy: <?php class foo { function bar() { $bar1 = "var1"; $bar2 = "var2"; $this->{$bar1}= "this "; $this->{$bar2} = "works"; } } $test = new foo; $test->bar(); echo $test->var1 . $test->var2; ?> --was-- I found another undocumented/cool feature: variable member variables in classes. It's pretty easy: class foo { function bar() { $bar1 = "var1"; $bar2 = "var2"; $this->{$bar1}= "this "; $this->{$bar2} = "works"; } } $test = new foo; $test->bar(); echo $test->var1 . $test->var2; http://php.net/manual/en/language.variables.variable.php

« previous php.notes (#157411) next »