Displaying code in my post

This should be 6 line of code:

 $runtime = $end - $start;
 <script type="text/javascript">
 var runtime2 = <?php echo $runtime; ?>; 
 document.getElementById("p1").innerHTML = runtime2;

Hmmm. Seems to work now.

So you’re just testing the system, not looking for a reply here?

Ah, you may have serendipitously discovered the “indent” way.

Personally, I prefer using the 3 backticks as it usually works the best for me.

What’s that? I don’t know that one.
I have noticed that if I paste in some code, copied from my editor, that is indented, like a lot of it is if it’s not not from the very root, things go a bit wrong if I highlight and make it code. I have to remove the indent to make it work.

That’s one of the main reasons I prefer using the three backticks on their own line before and after the code block eg.
var ask = query[0];

displays as

var ask = query[0];

I find it a lot easier than trying to edit in / out indentation.


  • type in 3 backticks
  • go to next line
  • paste code
  • go to newline
  • type in 3 backticks

Of course this assumes your keyboard has a backtick key (upper left below shift-tilde)

I had tried the backticks, but I was missing the new lines, that’s where I was going wrong. Thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.