lehi@here Posted August 22, 2007 Share Posted August 22, 2007 Hey guys, i've got a question about to create a script in PHP that will generate as output the script itself exactly..... ??? ??? ??? ??? can anyone help, please! thx. Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/ Share on other sites More sharing options...
corillo181 Posted August 22, 2007 Share Posted August 22, 2007 LOOPS? Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/#findComment-330698 Share on other sites More sharing options...
lehi@here Posted August 22, 2007 Author Share Posted August 22, 2007 maybe print the code itself. Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/#findComment-330700 Share on other sites More sharing options...
beboo002 Posted August 22, 2007 Share Posted August 22, 2007 use function() when u hav need the call the function(); Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/#findComment-330703 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 suppose u ve php file called 'temp.php' like, <?php .....some php code..... //to display php script show_source("http://url/temp.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/#findComment-330705 Share on other sites More sharing options...
lehi@here Posted August 22, 2007 Author Share Posted August 22, 2007 i think when the function is called, it should print the code itself. Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/#findComment-330711 Share on other sites More sharing options...
xyn Posted August 22, 2007 Share Posted August 22, 2007 use for() Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/#findComment-330839 Share on other sites More sharing options...
sasa Posted August 22, 2007 Share Posted August 22, 2007 try <?php $b = 5+2; echo $b; echo '<br />Sasa<br >'; // not output echo '<hr />script source:<br />'; echo '<pre>'; echo htmlentities(preg_replace('/[\r\n]*\/\/ not output.*not output[\r\n]*/s',"\r\n",file_get_contents($_SERVER['SCRIPT_FILENAME']))); echo '</pre><hr />'; // not output ?> Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/#findComment-330973 Share on other sites More sharing options...
lemmin Posted August 22, 2007 Share Posted August 22, 2007 file_get_contents("temp.php"); Will generate the script itself as output, however, if you want to print that to a page it is more complicated because it will be parsed. Quote Link to comment https://forums.phpfreaks.com/topic/66118-how-do-i-create-a-piece-of-code-that-reproduces-itself/#findComment-331001 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.