How to properly handle international character in PHP / MySQL / Apache

后端 未结 5 1853
我在风中等你
我在风中等你 2021-01-03 14:47

I need to create an application in PHP that can handle all Unicode characters in all places — edit fields, static HTML, database. Can somebody tell me the complete list of a

5条回答
  •  离开以前
    2021-01-03 15:36

    Some things you will need to look into:-

    PHP

    Make sure your content is marked as utf-8 :

    default_charset = "utf-8"

    Install mbstring. You can find it here

    Ensure that you are talking utf-8 between PHP and MySQL.
    Call mysql_set_charset("utf8"); (or use the SQL query SET NAMES utf8)

    Apache

    You also set the Content-Type: of your pages in here with something like this

    AddDefaultCharset utf-8

    MySQL

    Make sure all your tables use utf8 Collation utf8_general_ci; eg

    ALTER DATABASE mydb CHARACTER SET utf8;
    

    Finally

    Finally, test stuff with fun unicode samples, like these ones

    ٩(͡๏̯͡๏)۶

    More helpful information from when I tried this...

提交回复
热议问题