I discovered recently that to make my code postings look nice in Drupal, I needed to install the Code Filter module. Now when I enclose my code in <code> </code> tags, it comes out nicely formatted:
<?php
//here are some comments
//with "code" formatting
$some_variable = 123;
echo "some text";
?>