Friday, May 16, 2008

How to display HTML, PHP and JavaScript code on your blog

While writing some PHP and JavaScript code in another post here on sparktask I encountered the following problem: my code would be interpreted by the server and not displayed properly (if it all). After surfing the web for a solution I stumbled upon this website:

http://www.addressmunger.com/display_code/

The principle behind this solution is converting some or all the letters of your code to their ASCII counterparts. Although simple it works brilliantly. The downside of this solution is that if you try to later edit your post, all of the ASCII code will be reconverted to normal letters. The best way to avoid this disadvantage is to make sure you won't need to edit your posts.

2 comments:

Anonymous said...

Nice useful tip. I would have thought that only using single brackets is enough, but as I don't have a web blog, I didn't get to test that. Anyway, I guess you tried that before reading the ASCII thing. :))

Mohamed Thoufeeq said...

I didn't have any problem these days. I used to edit the text or content in the post regularly. But the HTML codes were still displaying in my post.
Now I have removed those posts because when ever I check my blog in Copyscape.com, it shows that the content is copied from some other blog, as the codes for displaying HTML snippets in your blog are general for most of the blogs.