Heim  >  Artikel  >  Backend-Entwicklung  >  php utf8跟utf-8的区别

php utf8跟utf-8的区别

WBOY
WBOYOriginal
2016-06-13 12:52:25804Durchsuche

php utf8和utf-8的区别
在使用中常常遇到utf-8和utf8,现在终于弄明白他们的使用不同之处了,现在来和大家分享一下,下面我们看一下utf8 和 UTF-8 有什么区别
“UTF-8”是标准写法,php在Windows下边英文不区分大小写,所以也可以写成“utf-8”。“UTF-8”也可以把中间的“-”省略,写成“UTF8”。一般程序都能识别,但也有例外(如下文),为了严格一点,最好用标准的大写“UTF-8”。
在数据库中只能使用“utf8”(MySQL) 在MySQL的命令模式中只能使用“utf8”,不能使用“utf-8”,也就是说在PHP程序中只能使用“set names utf8(不加小横杠)”,如果你加了“-”此行命令将不会生效,但是在PHP中header时却要加上“-”,因为IE不认识没杠的“utf8”,原因见下文。
PHP中的header:
//奇怪了:Content-Tyep用冒号,Chatset却是等号。
静态文件使用:
 
总结:【只有在MySQL中可以使用“utf-8”的别名“utf8”,但是在其他地方一律使用大写“UTF-8”。】
具体为:
  在命令“mysql_query(set names utf8)”外一律用大写“UTF-8”。
FROM:http://blog.csdn.net/ljfbest/article/details/6700148

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn