How to echo a string which contains <?php ?> -
i want generate php page contains html , php commands. problem when submit code below, output
<?php echo '$stfromyearerr '?><?php echo '$stfrommontherr '?><?php echo '$stfromdayerr '?> <?php echo '$sttoyearerr '?><?php echo '$sttomontherr '?><?php echo '$sttodayerr '?> rather php commands. how fix this?? thanks!!
<?php $page = "<html lang='en'> <head> <meta charset='utf-8' /> </head> <body><table width='990' border='0' align='center'><tr><td width='54%' colspan='2'> <span class='error'><?php echo '\$stfromyearerr ';?><?php echo '\$stfrommontherr ';?><?php echo '\$stfromdayerr ';?> <?php echo '\$sttoyearerr ';? ><?php echo '\$sttomontherr ';?><?php echo '\$sttodayerr ';?></span></td> </tr></table> </body></html>"; echo $page; ?>
you're echoing out php tags <?php, , presumably displaying in browser. look php code in browser, because browsers render < < it's not php code. it's text.
php not recursively executable, e.g.
<?php echo "<?php echo 'foo '; ?>"; ?> would echo out <, ?, p, etc..., not foo.
you can stuff
<?php $foo = "<?php echo 'hello world!'; ?>"; file_put_contents('hello.php', $foo); ?> without issues. long file you're producing gets executed php (e.g. don't name "hello.html"), php not know (or care) script produced other php code.
Comments
Post a Comment