note 82866 deleted from language.variables.variable by danbrown

From: Date: Wed, 24 Jun 2009 16:49:57 +0000
Subject: note 82866 deleted from language.variables.variable by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157388@lists.php.net to get a copy of this message
Note Submitter: fmouse at fmp dot com ---- You can use eval() to get around the limitation on using variable variables to reference superglobal arrays. e.g.: <?php # this fails: function indir($name) { $moe = $$name; echo "<pre>"; print_r($moe); echo "</pre>"; } indir("_SERVER"); # this works :-) function indir($name) { $moe = eval("return \$$name;"); echo "<pre>"; print_r($moe); echo "</pre>"; } indir("_SERVER"); ?>

« previous php.notes (#157388) next »