note 33522 added to function.eval
| From: | geoffrey at sickphp dot com | Date: | Sun, 29 Jun 2003 01:38:41 +0000 |
| Subject: | note 33522 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51161@lists.php.net to get a copy of this message | ||
interesting thing about eval, you can use passed vars, turn them into literals and use the values
for function arguments. sorry if this has already been done on this board:
//getvar: $_GET['term'] = "victory";
<?
//victory vars file
$victory['left'] = "works!"; // this would be in a separate file.
so you would need the "term"
from _GET to know what to do.
?>
<?
//mainfile
include_once("victory.inc");
$string = "\$_GET['term']";
eval("\$module = \"$\".$string.\"['left']\";");
eval("\$final = $module;");
echo $final;
?>
is there an easier way to do this? if you can understand my rambling ...
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33522
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33522&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33522&report=yes