How to assign eval() to variable?
| From: | Afan Pasalic | Date: | Sat, 23 May 2009 05:46:07 +0000 |
| Subject: | How to assign eval() to variable? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-292999@lists.php.net to get a copy of this message | ||
hi,
I have on one website boxes with information, pulled from mysql. the content can be string, php code, url of other website or url to specific file etc.
currently, I have something like this:
// connect to db
// mysql_query() to get box content and content_type
switch($content_type)
{
case 'string':
echo $content;
break;
case 'php_code':
eval($content);
break;
case 'website':
echo '<iframe>'.$content.'</iframe>;
break;
case 'file'
require_once($file);
echo $file_content;
// etc.
}
but, now I have to change the code to assign content to variable and the variable will be printed later. I tried something like this:
switch($content_type)
{
case 'string':
$record = $content;
break;
case 'php_code':
$record = eval($content);
break;
case 'website':
$record = '<iframe>'.$content.'</iframe>;
break;
case 'file'
require_once($file);
$record = $file_content;
// etc.
}
and it works - except eval() part. cant do $record = eval($content); ?!?!?!?
thanks
afan