简体   繁体   English

字符编码php mysql

[英]Character encoding php mysql

I have a table where the data are stored like boîtes with none utf8 characters. 我有一个表,其中的数据像boîtes一样boîtes ,没有utf8字符。 Now I have my php script which works fine on my local machine. 现在,我有了我的php脚本,该脚本可以在本地计算机上正常工作。

$utf = utf8_decode($details);
echo "UTF8-DE : ".$utf."<hr>";-> `boîtes`

When I put this script on another machine its not working its echoing boîtes . 当我将此脚本放在另一台计算机上时,它的回boîtes I am sure it depends on the charset of the php or server? 我确定这取决于PHP或服务器的字符集? Any help please 任何帮助请

用标题设置

header('Content-type: text/html; charset=utf-8');

Try set_charset function 尝试set_charset函数

For mySqli 对于mySqli

mysqli_set_charset($connection, "utf8");

For mySql 对于mySql

mysql_set_charset("UTF8", $connection);

Alternative 另类

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_unicode_ci'");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM