PHP UTF-8 Output


  • If your application transmits text to other systems, they will also need to be informed of the character encoding. In PHP, you can use the default_charset option in php.ini, or manually issue the Content-Type MIME header yourself. This is the preferred method when targeting modern browsers.

    header('Content-Type: text/html; charset=utf-8');
  • If you are unable to set the response headers, then you can also set the encoding in an HTML document with HTML metadata.

    • HTML5

      <meta charset="utf-8">
    • Older versions of HTML

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