Re: Show php code
| From: | Frappy John | Date: | Sat, 12 Apr 2003 20:21:16 +0000 |
| Subject: | Re: Show php code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143621@lists.php.net to get a copy of this message | ||
> How can i make a print to the screen of php (or even
> html) code without executing it?
If you want to display an entire source file via your
server, the simplest way is to rename your .php file with a
.txt extension or, if you want to retain the file as
working php, make a symbolic link to it:
ln -s mysource.php mysource.txt
Most servers are configured to treat a .txt file as plain
text and include a mime header to that effect. Most
browsers will honor the header. (If your file *begins* with
an <html> or <?xml> tag, however, some browsers will format
it despite the header. So start with <?php> or plain text. )
If, however, you want to include the source as part of a
formatted HTML page, you will have to replace all the "<"s
and ">"s with "<" and ">". A regular expression
should do the trick.
A quick and dirty workaround (to avoid learning regex :) is
to include your code in a <form><textarea>. That seems to
come through in raw format.
(The HTML <code> tag you tried to use is for formatting
purposes only, i.e. to make the code look like code [i.i.e.
printed in a crude lineprinter font :] It's not specific
to any programming language.)
--John
On Saturday 12 April 2003 12:47 am, Pag wrote:
> HI again,
>
> How can i make a print to the screen of php (or even
> html) code without executing it? I mean, i want to
> display some php/html code on the site without the
> browser interpreting it.
> I tried using,
>
> <CODE>
> insert html/php here
> </CODE>
>
> but doesnt work.
>
> Thanks.
>
> Pag