-5

This question already has an answer here:

I want to know how to add code tags in this editor. As an example if I want to post an answer in PHP, as soon as I type "open php" my line disappears. How to post PHP with open and close?

marked as duplicate by Arulkumar, PolyGeo, rene, Bart, gnat Jul 6 '17 at 12:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    type code, select it and press ctrl + k – Optimus Prime Jul 6 '17 at 11:29
  • Or 4 space indentation for each line and a blank line just above the first line. – Optimus Prime Jul 6 '17 at 11:30
5

You should indent code by 4 spaces. This puts it in

code markdown

Alternatively, you can put the code between backticks. This also puts things in code markdown.

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!

Not the answer you're looking for? Browse other questions tagged .