0

I am writing a blog and when I display code, I usually do so like this:

< pre > < code > Code Goes Here < / code > < / pre>

But it will not display the starting of php <?php or the end ?> and I really need it to. Any suggestions?

Thanks.

4

4 Answers 4

4

To display special characters in HTML, you must escape them.

< - &lt;
> - &gt;
& - &amp;
" - &quot;
' - &#039;

So in your case, you want

<pre><code>&lt;?php (PHP CODE HERE) ?&gt;</code></pre>

(Also notice the order of closing tags must match the order of opening tags.

Sign up to request clarification or add additional context in comments.

Comments

1

Use &lt;?php and ?&gt;

Comments

1
 <pre><code>&lt;?php Code Goes Here ?&gt;</code></pre>

Comments

0

I am not sure how blogs work but you can try the php function "highlight_string();" like this:

<?php
highlight_string('<?php phpinfo(); ?>');
?>

It will output the ('input') as a string with colorcoding. check out its php documentation: http://php.net/manual/en/function.highlight-string.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.