Monthly Archives: September 2013

PHP htmlentities not working

If you find yourself in a situation where htmlentities() function is not working, don’t be alarmed there is a fix. Here’s what I found through my research:

Let’s take a french character “è” and convert it to an htmlentity:

If you print the output it will look exactly what you started with. Now, if you apply the strtoupper() function to the same variable before printing it, the character will no longer be decoded by the browser and will display html entity code, like this: è

This happens because the HTML friendly code is case sensitive, be careful when doing this. One of many alternatives is to use CSS to transform text to upper case.