How to best configure PHP to handle a UTF-8 website [duplicate]

The supposed issues of PHP with Unicode content have been somewhat overstated. I’ve been doing multilingual websites since 1998 and never knew there might be an issue until I’ve read about it somewhere – many years and websites later.

This works just fine for me:

Apache configuration (in httpd.conf or .htaccess)

AddDefaultCharset utf-8

PHP (in php.ini)

default_charset = "utf-8"
mbstring.internal_encoding=utf-8
mbstring.http_output=UTF-8
mbstring.encoding_translation=On
mbstring.func_overload=6 

MySQL

CREATE your database with an utf8_* collation,
let the tables inherit the database collation and
start every connection with "SET NAMES utf8"

HTML (in HEAD element)

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Leave a Comment