cranberry13 Posted January 24, 2008 Share Posted January 24, 2008 At the end of one my scripts, I want to display another script (ie. call another program) and have that displayed to the user. Does php have a function for this? What is an elegant way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/87485-how-to-print-the-contents-of-a-php-script-from-another-script/ Share on other sites More sharing options...
cooldude832 Posted January 24, 2008 Share Posted January 24, 2008 http://us2.php.net/manual/en/function.show-source.php Quote Link to comment https://forums.phpfreaks.com/topic/87485-how-to-print-the-contents-of-a-php-script-from-another-script/#findComment-447458 Share on other sites More sharing options...
cooldude832 Posted January 24, 2008 Share Posted January 24, 2008 this will echo out the file itself <?php highlight_file($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/87485-how-to-print-the-contents-of-a-php-script-from-another-script/#findComment-447461 Share on other sites More sharing options...
cranberry13 Posted January 24, 2008 Author Share Posted January 24, 2008 Thanks CoolDude, Another question for you -- the both scripts (the caller and the callee) are under a htpasswd protected folder. When I used showsource in the program both with and without the http I got the following error: Warning: show_source(http://www.mydomain.com/admin/display.php?id=24): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in /home/myuser/public_html/admin/submit.php on line 41 What do you suggest? Quote Link to comment https://forums.phpfreaks.com/topic/87485-how-to-print-the-contents-of-a-php-script-from-another-script/#findComment-447481 Share on other sites More sharing options...
cooldude832 Posted January 24, 2008 Share Posted January 24, 2008 the chmod would require the "public" to view the file so set chmod(0777) on it this should only be used for viewing purposes (not any html purposes), if you are trying to show source code in a page for tutorial purposes use it as a separate file and say highlight_file($file_to_show) where file to show isn't the parent doc but the one you wish to be displayed. Quote Link to comment https://forums.phpfreaks.com/topic/87485-how-to-print-the-contents-of-a-php-script-from-another-script/#findComment-447483 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.