Here is the Markdown Syntax page.
I'm not exactly sure what you want to achieve.
You have something like the following right?
#Heading
<code>
$my = 'php code here';
</code>
Other text
Do you want your output to be like the one below?
<h1>Heading</h1>
<code>
$my = 'php code here';
</code>
<p>Other text</p>
For code in markdown you have to indent the code by four spaces so what you should do is the following in your markdown source file.
#Heading
$my = 'php code here';
Other text
The code is indented four spaces and markdown will surround it with and tags automatically.