note 82610 rejected from language.variables.predefined by nlopess
| From: | nlopess@php.net | Date: | Sat, 19 Apr 2008 23:16:39 +0000 |
| Subject: | note 82610 rejected from language.variables.predefined by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-138551@lists.php.net to get a copy of this message | ||
Note Submitter: sano at pstudio dot ru
----
When I tried to assign $_GET,$_POST,$_REQUEST or any superglobal variable in any method of my
classes like this:
<?php
class myClass {
function __construct(){
$vars = array("_POST","_GET","_REQUEST");
foreach ($vars as $varName)
{
$this->$_varName = ($$varName);
}
}
}
?>
I've got error message "Notice: Undefined variable: _POST in *** on line 8"
The only solution I've found for this problem is using eval();
eval("\$_tmp = \$".$varName.";");
$this->$_varName = ($_tmp);
Anyone knows other ways to solve this problem?