PHP garbled problem, UTF-8 (garbled), very full explanation and solution.
.HTML page to UTF-8 coding problem
1. after head, title before adding a line:
[code].lt; meta http-equiv='Content-Type'content='text/html; Random code!
2.html file coding problem:
click the editor's menu: "file" -.gt; "save as", you can see the code of the current file, ensure that the file is encoded to: UTF-8,
if it is ANSI, you need to change the code to UTF-8.
3.HTML file header BOM problem:
when converting files from other codes to UTF-8 codes, sometimes at the beginning of the file, add a BOM tag,
in a BOM tag may cause the browser to appear in Chinese when the browser appears chaotic code.
delete the BOM tag:
a. can open the file with Dreamweaver and save it again, that is, you can remove the BOM tag!
b. can open the file with EditPlus, and in the menu "preference" -.gt; "file" -.gt; "UTF-8 logo", set to "always delete the signature",
save the file, that is, you can remove the BOM tag!
4.WEB server UTF-8 coding problem:
if you do the steps listed above, or there is a Chinese random code problem,
please check your WEB server coding problem
if you are using Apache, please set the configuration file: charset to UTF-8 (here only list methods, tools. Please refer to Apache's configuration file)
if you use Nginx, please set the nginx.conf: charset to UTF-8,
to find "charset GB2312;" or similar statements, to "charset UTF-8;".