html - PHP code gets commented out -
i have following problem within following script
php code:
$var = file_get_contents('template/default/index.php'); $content1 = str_replace('{php}','<?php',$var); $content2 = str_replace('{/php}','?>',$content1); echo $content2; template/default/index.php code:
<!doctype html> <html> <body> <h1>my first heading</h1> <p>my first paragraph.</p> {php} echo 'worked'; {/php} </body> </html> i'm trying transform {php}{/php} tags within template/default/index.php propper php tags. happends, php code gets commented out. browser gives in return:
<h1>my first heading</h1> <p>my first paragraph.</p> <!--?php echo 'worked'; ?--> does know how solve this?
instead of echoing out replaced content, should eval'd. although don't recommend that.
Comments
Post a Comment