htmlentities() bites the dust

Feb 10, 2004

I've used the PHP function htmlentities() for years, making my text safe to print to the screen and still remain XHTML Strict.

Well, all that changed today when I discovered the not only does htmlentities() make a string safe to print, it also translates UTF-8 encoded characters into so much gibberish.

So instead of htmlentities(), I now use htmlspecialchars() which only translates a select few characters. And looking back, unless there's a really, really, really good reason, you should always be using htmlspecialchars()

I learn something new every day :/

Orca Script Rebuild Why you shouldn't use CSS selector bugs

Comments closed

Recent posts

  1. Current Bitcoin Cash Price Image Mar 2018
  2. Iguana no Musume / Iguana Girl Aug 2016
  3. What I'd Like To See In The Elder Scrolls VI - Part 2 Aug 2015
  4. What I'd Like To See In The Elder Scrolls VI Jul 2015
  5. Cyprus, and what capitalists want Mar 2013
  6. Archive

Items of Interest

Webcomics Reading List

Good Eats