Skip to content

Instantly share code, notes, and snippets.

@embayer
Last active August 29, 2015 14:08
Show Gist options
  • Save embayer/385b7fe30684ad921782 to your computer and use it in GitHub Desktop.
Save embayer/385b7fe30684ad921782 to your computer and use it in GitHub Desktop.

PHP UTF-8

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 Database with an utf8_* collation
  • let the tables inherit the database collation
  • start every connection with "SET NAMES utf8"

HTML (in HEAD element)

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment