Home > Database > Mysql Tutorial > body text

PHP乱码来源分析

WBOY
Release: 2016-06-01 13:15:53
Original
1004 people have browsed it

PHP项目出现乱码,原因就是软件之间,模板之间的编码有差异,不相同:

  1. 新建".html", ".php" , ".tpl" , ."js" , ".css"等文件使用utf8统一的编码格式;
  2. 开发工具中设置默认新建文件时的编码格式;
  3. mysql_query("set character set 'utf8'");          //读库

  4. mysql_query("set names 'utf8'");                  //写库

  5. default-character-set=utf8                         //MySQL配置文件"my.ini"编码设置
  6. init-connect=/'SET NAMES utf8/'                 //MySQL配置文件"my.ini"编码设置
  7. collation_server=utf8_unicode_ci               //MySQL配置文件"my.ini"编码设置
  8. character_set_server=utf8                       //MySQL配置文件"my.ini"编码设置
  9. default_charset = "UTF-8"                       //php配置文件"php.ini"编码设置
  10. header(“Content-Type: text/html; charset=utf-8″);    //php 文件输出头
  11. header("Cache-Control:no-cache");                          //php文件输出头
  12.       //html页面中使用的编码

  13. 在phpMyAdmin中修改mysql中数据库,数据表及数据字段的字符编码格式;                //编码设为:utf8_general_ci
  14. 数据库执行语句 :CREATEDATABASE`dbname`DEFAULTCHARACTERSETutf8 COLLATE utf8_general_ci;
  15. 待续...

补充: 
# Lang-abbvCharset     Language
#---------------------------------
en         ISO-8859-1  English
UTF-8      utf8        UTF-8
Unicode     ucs         Unicode
th          Cp874       Thai
ja          SJIS        Japanese
ko          Cp949       Korean
zh          Cp950       Chinese-Traditional
zh-cn      GB2312      Chinese-Simplified
zh-tw       Cp950       Chinese
cs          ISO-8859-2  Czech
hu          ISO-8859-2  Hungarian
hr          ISO-8859-2  Croation
pl          ISO-8859-2  Polish
ro          ISO-8859-2  Romanian
sr          ISO-8859-2  Serbian
sk          ISO-8859-2  Slovak
sl          ISO-8859-2  Slovenian
sq          ISO-8859-2  Albanian
bg          ISO-8859-5  Bulgarian
be          ISO-8859-5  Byelorussian
mk          ISO-8859-5  Macedonian
ru          ISO-8859-5  Russian
uk          ISO-8859-5  Ukrainian
ca          ISO-8859-1  Catalan
de          ISO-8859-1  German
da          ISO-8859-1  Danish
fi          ISO-8859-1  Finnish
fr          ISO-8859-1  French
es          ISO-8859-1  Spanish
is          ISO-8859-1  Icelandic
it          ISO-8859-1  Italian
nl          ISO-8859-1  Dutch
no          ISO-8859-1  Norwegian
pt          ISO-8859-1  Portuguese
sv          ISO-8859-1  Swedish
af          ISO-8859-1  Afrikaans
eu          ISO-8859-1  Basque
fo          ISO-8859-1  Faroese
gl          ISO-8859-1  Galician
ga          ISO-8859-1  Irish
gd          ISO-8859-1  Scottish
mt          ISO-8859-3  Maltese
eo          ISO-8859-3  Esperanto
el          ISO-8859-7  Greek
tr          ISO-8859-9  Turkish
he          ISO-8859-8  Hebrew
iw          ISO-8859-8  Hebrew
ar          ISO-8859-6  Arabic
et          ISO-8859-1  Estonian
lv          ISO-8859-2  Latvian
lt          ISO-8859-2  Lithuanian
                       

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!