PHP garbled problem, UTF-8 (garbled), very full explanation and solution.

time:14-10-07 forum:PHP tools and code
  Reprinted from http://www.phpdo.net/php-garbled-utf-8.html
.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;".
  • 2
  • 3
  • 4
  • 5

prev:PHP code instance for importing SQL scri... next:PHP reads all the same types of files un...
post comment
Notice



approved   After graduation, I learned about th...   "Tang Ye Da Ma" on Chuang Cheng Road   2 teachers and 7 children were both ...   PHP cURL to achieve simulation login...   The 78 year old academician sits on ...
rand   PHP code for different cities from I...   Website 301 turn to Encyclopedia   Super PHP rapid programmer   PHP regular expression summary   PHP probability operation function
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com