Some characters become “�” in our webpage

前端 未结 3 547
挽巷
挽巷 2021-01-23 19:02

I use PHP to access a database to get a string like this

‘Chloe’ Fashion Show & Dinner

and then I do a printf() to output the st

3条回答
  •  轮回少年
    2021-01-23 19:37

    1. Check if your .php file is encoded as UTF-8 without BOM
    2. Check that your connection to the database is UTF-8
    3. Check that you send in your HTML markup in the tag

    If your connection to the database is not UTF-8 and you don't want to change it (but I recommend it -> everything UTF-8 is the most secure solution against character rubbish) use utf8_encode($databaseValue) to ensure the encoding of your value is UTF-8.

提交回复
热议问题