Hi
First off make sure you omit the <? or <?php tag that tells the server to run your code, that will cause your code to be displayed.
If you surround the code in the <PRE></PRE> tag this will keep the code looking exactly as you have it in the source with line breaks and all.