Heim  >  Artikel  >  php教程  >  PHP开发中utf8、utf

PHP开发中utf8、utf

WBOY
WBOYOriginal
2016-06-06 19:49:221338Durchsuche

相信很多PHPer刚开始也会有这样的疑惑,四处碰壁后总结如下: 一、UTF-8这是标准写法,在PHP和HTML中设置编码,统一写成UTF-8。 举例: PHP中 ?php header('Content-Type: text/html; charset=UTF-8'); ? HTML中 meta http-equiv="Content-Type" content="te

  相信很多PHPer刚开始也会有这样的疑惑,四处碰壁后总结如下:

  一、“UTF-8”这是标准写法,在PHP和HTML中设置编码,统一写成“UTF-8”。
  举例:
  PHP中 ——
  HTML中 —— 

  二、“utf8”、“utf-8”和“UTF8”只是在window中不区分大小写的写法而已,一般程序能识别,但也有例外。例如简写的“UTF8”或“utf8”在ie浏览器里不识别。

  三、数据库命令模式中,必须写成“utf8”,因为MySQL的命令模式中只能识别“utf8”,比如:PHP程序中可以写:
    mysql_set_charset('utf8',$link);
  ?>

  结论:MySQL操作使用“utf8” 【mysql_query(set names utf8)】,其他一律使用“UTF-8”。

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
Vorheriger Artikel:PHP 解决未定义变量报错Nächster Artikel:window+nginx+php