I get asked quite often if there is a way to show CODE on a website, with it’s formatting in place?

The short answer is <pre>

It can output free text (i.e. non server side code) in a pre-formatted way. Yep, PRE = Pre-formatted.

On top of that, Preformatted also renders the php print_r() output in a nicely nested unordered list, which is great for debug purposes;

e.g.
[sourcecode language=’php’]  echo ”

";    print_r($arr);  echo "

“; [/sourcecode]

I am sure there are other uses for the <pre> tag too, I have just scratched the surface.

Give it a go – let me know if you find other uses for it.

Thanks.