treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Display HTML code with PHP

  • 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?
  • I believe Chris uses Google Prettify.
  • 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.