PHP MySQL and Special Characters

You may find that you have a problem with special characters not displaying or showing up as a small black diamond with a ? in the center. Here’s a quick fix seems to work well.

These would be characters like: <, > and &. It also includes characters like: é,?, ø and the curly quotation marks.

At the point you are printing these characters into a page you’ll want to run them through the php htmlentities function. Here’s an example:

htmlentities( $str, ENT_COMPAT, 'Windows-1252' );

Where $str would be any string you wanted to convert to compatible characters.

For more info:

Leave a Reply

Your email address will not be published. Required fields are marked *