note 65314 deleted from language.variables.variable by philip
| From: | philip@php.net | Date: | Sun, 28 Jan 2007 17:50:21 +0000 |
| Subject: | note 65314 deleted from language.variables.variable by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122295@lists.php.net to get a copy of this message | ||
Note Submitter: Florian Sonner
----
If you have to access to variable variables in a method (or function) you can simply use the
workaround below. That little example should print a list with all variables in $_POST. And if you
want to access to the elements of the array, take a look at Shawn Beltz (thank you for the basic
idea ;-) ) Note.
<?php
class Foo
{
private $superglobal = 'POST';
public function Bar()
{
var_dump(eval("return \$_$this->superglobal;"));
}
}
$f = new Foo();
$f->Bar();
?>