note 45643 deleted from function.eval by tomsommer

From: Date: Mon, 13 Sep 2004 22:01:54 +0000
Subject: note 45643 deleted from function.eval by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76646@lists.php.net to get a copy of this message
Note Submitter: mmrtnt at earthlink dot net ---- Just searching the documentation for $$ doesn't appear to return any valid results. I think this use of the operator is very similar to some of the uses of eval(), so I'm going to mention it here. If there's some fundamental reason why this is bad, I would really appreciate it if someone would let me know. Instantiating variables on the fly can be really useful. I'm sure there are better ways to get a form's values as PHP vars, but this example is used just to illustrate how the $$ operator works. Given: <form> <input type="text" name="name" value=""> <input type="text" name="email" value=""> <input type="text" name="phone" value=""> </form> You can then do this: <?php foreach( $_POST as $key => $value ) { $$key = $value; } ?> This will give you $name, $email and $phone with the values inputted by the user. MjM

« previous php.notes (#76646) next »