HTML views exact source - no parsing

hey - I am going to do a presentation soon about some code that i've been writing.  It would be really nice to have a popup that just displays the code (I know it can open a wordpad thing using javascript but I want this in an actual webbrowser).  In other words I want to have this done automaticly I DO NOT WANT TO go through all my code change it from this:

to this: (sorry about the spaces...needed for you to see what I want)
& l t ; head & g t ;
& l t ;title & g t ;TITLE& l t ;/title & g t ;
& l t ;/HEAD & g t ;

ALSO - I would like to do the same with PHP code.  Thanks in advance
Who is Participating?
dorwardConnect With a Mentor Commented:
Put the code in a .txt file, most servers are configured to send files with a .txt extension as text/plain. Unfortunatly MSIE thinks it knows better then you and will treat it as HTML anyway, but you can get around that by using Mozilla, Opera or Netscape.

Or - use search and replace to change & to &amp; then < and > to &lt; and &gt;

As for PHP - stick it in a .phps file. Most servers that can cope with PHP will syntax highlight it for you. Come to think of it, that will probably work for your HTML too.
<a href="view-source:">view source</a>
and more generally:

<a href="#" onclick="location='view-source:'+this.href;return false;">view source</a>
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

What's wrong with just right clicking and choosing VIEW SOURCE? You're the one doing the presentation, right?
true.  alternatively, you can view the source of multiple sites / pages from one page like this:

<a href="#" onclick="location='view-source:'+this.href;return false;">view THIS source</a> <br />
<a href="" onclick="location='view-source:'+this.href;return false;">view EE source</a> <br />
<a href="" onclick="location='view-source:'+this.href;return false;">view FOX source</a> <br />
This is better than View Source.  The easy answer, and an invaluable resource, is the View Partial Source tool for IE.  Microsoft says it's not supported for IE6 for some reason, but it works fine.  You can find it at:   Their description: "...for those who are tired of scrolling through hundreds of lines of HTML to find that one section of code that does what you want, search no more! Simply highlight the area of Web page that you want to see the source for, right click on it and select 'View Partial Source.' It's that simple! "

It shows you the source as IE reads it, so your quotes and the order of attributes and stuff like that are not preserved.  But you can download it in 30 seconds and use it for your presentation.  The only caveat is that you need to close the window that pops up after each view, or else the script driving the thing breaks.

This tool also lets you see not just the html - BUT ALSO the value of hidden form fields as they're set by script.  So you look at the initial page, view partial source, then do some action and view partial source again and you can see if your form fields are being set to the right values.  I recommend this tool to EVERY web developer out there, it's great.

It only shows HTML though, nothing server side (like PHP).  There you're out of luck.

For server-side code, you're going to have to either open the file using PHP methods, write it to a buffer, RegEx through it to change what you want to change, and print out the result, OR open the file using PHP methods, write the file to a text file, and open the text file.

With a little elbow grease, you could probably write a function that would iterate over a directory and write all of the files to text files. You could call that function from an admin page just before your presentation (or any future presentation) and have the TXT files at your disposal.
joshenceAuthor Commented:
the *.phps is exactly what I wanted.  AWESOME.  

Thank you so much
joshenceAuthor Commented:
sorry I accepted this before and forgot to give you a grade.  Thanks again dorward
All Courses

From novice to tech pro — start learning today.