Use the eval() function.
$sString = "?>hello this is <? echo 'my'; ?> string<?";
eval($sString);
Note: the string in the eval() function has to be valid PHP code as found between the <? and ?> tags.
so this is valid:
<? echo "hello"; ?>
and this is not:
hello <? echo 'there';?> how are you
but this is:
?> this is not PHP code <? echo 'and this is'; ?> and this isnt <?
because the PHP is stopped by ?> and re-started by <?
Remember, this EXECUTES the code in the string, so if there is an "exit" command in the string, your entire script will stop, not just the the eval() function.