Shoutbox

PHP Display Code - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: PHP Display Code (/showthread.php?tid=49097)

PHP Display Code by DJeX on 08-17-2005 at 09:04 PM

What php code would I used to display code inside another php file.

Like for example:

Say I have a php file at: http://www.myhost.com/myfolder/test.php

And I want to have a seprate php page to display the php code in that file on the screen. How would I do this?

I thought this may work but I'm not sure.

code:
<?php
echo http://www.myhost.com/myfolder/test.php
?>

RE: PHP Display Code by Millenium_edition on 08-17-2005 at 09:06 PM

http://www.php.net/include/


RE: PHP Display Code by DJeX on 08-17-2005 at 09:33 PM

Ok I used this:

code:
<?php

$show = include 'http://www.myhost.com/myfolder/myphp.php;

echo $show;

?>

But it does not show the PHP code of that file it shows the number 1.

Can any one help?
RE: PHP Display Code by absorbation on 08-17-2005 at 09:37 PM

<?PHP



include("name.php");

?>

the page extension must be php :P i use it so i can update pages quicly


RE: PHP Display Code by DJeX on 08-17-2005 at 09:42 PM

Will that display the code of a php file on the screen?


RE: PHP Display Code by segosa on 08-17-2005 at 09:43 PM

The php file will be parsed on the remote server before being downloaded.. so no, it won't. Change the file on the remote server to .txt so no parsing is done if you want the code to be downloaded.

If you don't want it parsed locally, you can't use include() either. try readfile();


RE: PHP Display Code by Stigmata on 08-17-2005 at 09:46 PM

dude...

http://uk2.php.net/show_source


RE: PHP Display Code by wj on 08-17-2005 at 09:46 PM

http://us2.php.net/manual/en/function.highlight-file.php


RE: PHP Display Code by Stigmata on 08-17-2005 at 09:50 PM

quote:
Originally posted by wj
http://us2.php.net/manual/en/function.highlight-file.php

beat you to it :D



RE: PHP Display Code by DJeX on 08-17-2005 at 10:27 PM

how would I use highlight_file()?


RE: PHP Display Code by Ezra on 08-17-2005 at 10:30 PM

I tried it too, and I didn't get it to work :P


RE: PHP Display Code by Stigmata on 08-17-2005 at 10:33 PM

http://aidan.dotgeek.org/lib/?file=PHP_Highlight.php

that seemed helpful


RE: PHP Display Code by DJeX on 08-17-2005 at 11:44 PM

When I use that code I get this error.

code:
Warning: main(PHP/Compat/Constant/T.php): failed to open stream: No such file or directory in /home/---------/public_html/---/PHP_Highlight.php on line 11

Fatal error: main(): Failed opening required 'PHP/Compat/Constant/T.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/---------/public_html/---/PHP_Highlight.php on line 11

I've blanked out the parts on the links with ----- just so ya know.
RE: PHP Display Code by WDZ on 08-18-2005 at 04:57 AM

quote:
Originally posted by DJeX
When I use that code I get this error.
Well, the comments say...

code:
* The source of this file can be found at:
* http://cvs.php.net/co.php/pear/PHP_Compat/Compat/Constant/T.php?r=HEAD
*
* It is part of the PEAR PHP_Compat package:
* http://pear.php.net/package/PHP_Compat
So apparently you need to have that "T.php" file uploaded for the script to work.