note 15340 deleted from function.eval by jimw

From: Date: Sat, 08 Dec 2001 23:25:48 +0000
Subject: note 15340 deleted from function.eval by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22328@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

« previous php.notes (#22328) next »