the Title descripe it:
How to echo the
$string = str_replace("<?php","<?php",$string);
PHP is not recursively embeddable. The following
<?php echo "<?php echo 'Hi mom!' ?>";
Will output the literal characters
p etc... The "internal" echo will NOT be executed, because it's not PHP code - it's just some characters in a string.
Note that if you're outputting this text into an HTML context (e.g. a web browser), the
<?php tag WILL be mis-interpreted as an invalid/illegal HTML tag, and be skipped by the browser. In which case, you have to do
echo "<?php echo 'hi mom!' ?>"
Remember - you're not outputting PHP code, you're outputting text, and if it's going into a web page, that text has to be VALID html.