
Originally Posted by
misson
I take it you're processing the file before you want PHP to evaluate it, and thus can't use include. You could try prepending '?>' to the string you pass to eval.
Yes, I'm proccesing the file before showing it, and spliting it up into parts, leaving me with two strings. The first is broken up into an array to make the page details, and the second is the body of the page (where i want to include the php code).
This is the new part of the code using eval.
PHP Code:
<?php
function phpRun($code) {
ob_start();
$code = stripslashes( $code );
$code = html_entity_decode( $code );
$code = "?>".$code."<?php ";
eval($code);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
$bbtext = str_replace("}\n", "}", $text);
$bbtext = str_replace("\"", '"', $text);
$match = array('#\{php\}(.*?)\{\/php\}#se');
$replace = array( phpRun( '$1' ) );
$bbtext = preg_replace($match, $replace, $bbtext);
?>
This returns:
HTML Code:
Parse error: syntax error, unexpected T_ECHO in /home/ziaix/public_html/projects/wrapper/wrap.php(64) : regexp code on line 1
Fatal error: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Failed evaluating code: echo \"this is PHP!\"; in /home/ziaix/public_html/projects/wrapper/wrap.php on line 64