Treehouse: Grow your CSS skills. Land your dream job.

Display HTML code with PHP

  • # April 11, 2012 at 9:14 pm

    As you probably all know, we can display code here in <pre><code></pre></code> tags.
    But how can we do that on our own pages without using <xmp> (outdated) ?

    I guess it can be done with htmlentities(), but how can I make the <code> tag always have text within it run through htmlentities() first so as to display the tags?

    # April 11, 2012 at 10:03 pm

    I believe Chris uses Google Prettify.

    # April 12, 2012 at 2:12 am

    The code would seem to suggest that, but when I was looking for this on the internet (how to display the code) I heard about prettify only making the text a different colour and not showing the code (unless escaped).
    I’ll give it a try.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.