note 70409 deleted from function.eval by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 19:55:13 +0000 |
| Subject: | note 70409 deleted from function.eval by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155293@lists.php.net to get a copy of this message | ||
Note Submitter: Joeri
----
This is a variation on the contribution of Matt's note, to load a php file into a variable and
then evaluate it (which works perfect).
This snippet does almost te same, but instead of sending it back to the browser, it sends it back to
a variable.
<?PHP
function phpWrapper($content) {
ob_start();
$content = str_replace('<'.'?php','<'.'?',$content);
eval('?'.'>'.trim($content).'<'.'?');
$content = ob_get_contents();
ob_end_clean();
return $content;
}
$content = file_get_contents('feedback.php');
$content = phpWrapper($content);
// $content will now contain your evaluated code :)
?>