Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mysql中的字符编码问题_Php_Mysql_Character Encoding - Fatal编程技术网

Php mysql中的字符编码问题

Php mysql中的字符编码问题,php,mysql,character-encoding,Php,Mysql,Character Encoding,在我的数据库中,我有一些类似的内容 header('Content-Type: text/html; charset=utf-8'); അവരുടെ മനസ്സുകളില്‍ 但是,当我尝试使用PHP获取内容并在broswer中显示时,它只显示一些问号,如 我试图像这样设置内容类型标题 header('Content-Type: text/html; charset=utf-8'); 但它不起作用 我怎样才能解决这个问题?任何帮助都将不胜感激。它不起作用,因为您在获取数据时损坏了它,并且您正

在我的数据库中,我有一些类似的内容

header('Content-Type: text/html; charset=utf-8');
അവരുടെ മനസ്സുകളില്‍

但是,当我尝试使用
PHP
获取内容并在broswer中显示时,它只显示一些问号,如

我试图像这样设置内容类型标题

header('Content-Type: text/html; charset=utf-8');
但它不起作用


我怎样才能解决这个问题?任何帮助都将不胜感激。

它不起作用,因为您在获取数据时损坏了它,并且您正在设置显示编码-已经太晚了。只需在连接过程中使用适当的方法(如
mysqli\u set\u charset()
)或在连接到DB后立即查询
set NAMES UTF8
,即可确保正确编码。根据连接到DB的方法,您应该指定字符集

使用PDO,您可以在
PDO::\uu construct()
中指定字符集,例如:
charset=UTF-8

否则,您必须使用MySQLi,否则上帝禁止您仍在使用
mysql.*
函数