[UPHPU] HTML/PHP via eval()
Jacob Wright
jacwright at gmail.com
Sat Aug 27 10:22:31 MDT 2005
eval() is assuming that you are already starting in PHP mode, so you'll have
a heck-a-time trying to parse through the whole string to modify it to work
and it will also be innefficient. I just tested this out, so I'm not sure if
it works in all cases, but, if you want to eval a PHP page, then just add a
?> in front of the string. Here is an example:
eval('?><html><body><?php echo "hello world!" ?></body></html>');
> function eval_mixed($string){
> $string = "<? ?>".$string."<? ?>";
> $string = preg_replace("/<\?=\s+(.*?)\s+\?>/", "<? echo $1; ?>", $string);
> $string = str_replace( array('<?php', '<?'), '',
> preg_replace_callback( "/\?>((.|\n)*?)<\?/",
> create_function(
> '$arr',
> 'return ("echo
> stripslashes(\"".addslashes($arr[1])."\");");',$string) ) );
> $string = str_replace('?>', '', $string);
> return eval($string);
> }
Could instead be:
function eval_mixed($string){
return eval("?>$string");
}
I know it's not as cool looking as the above function, but hopefully it will
do the trick! ;)
Jacob
More information about the UPHPU
mailing list