PHP tag in post content makes wordpress go crazy

If you only want the php code to be output without executing it, just escape the < signs by replacing it with the html entity &lt;.

&lt;?php

Like this, the tag will not be recognised and will be output as <?php.