note 15340 added to function.eval
| From: | buddy at www dot zabiny dot cz | Date: | Thu, 06 Sep 2001 08:32:40 +0000 |
| Subject: | note 15340 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17713@lists.php.net to get a copy of this message | ||
Very simple way how to initialize variables of class using eval and array of variable names:
class example {
var $relParams;
function initParams ($args)
{
//here initialize the array $relParams
}
//make the params available as $object->varialbename after you already initialized object as
$object = new example:
function global_relParams ()
{
for ($i = 0; $i < count($this->relParams); $i++) {
$varName = $this->relParams[$i];
eval ("global \$$varName;");
eval ("\$this->\$varName = \${\$varName};");
}
}
}
happy codding
http://www.php.net/manual/en/function.eval.php