You should indent code by 4 spaces. This puts it in
Alternatively, you can put the code between backticks. This also puts things in
As @Sagar V observes in their comment, you can just select the code block, and click ctrl+k. This also indents the code by 4 spaces.
The reason your PHP code seems to disappear, is that it opens with "<". Now the editor thinks it's markup, and tries to treat it as such.
By putting your PHP in code markdown, the editor knows that it is code and should be formatted as such.
Please use code markdown only for code!