为什么我必须使用set_charset(“utf8”),即使一切都是utf-8编码? (MySQLi-PHP) [英] Why do i have to use set_charset("utf8") even though everything is utf-8 encoded? (MySQLi-PHP)
问题描述
我的表的排序规则是utf8_general_ci。
我的网页使用UTF-8编码(不含BOM)。
在我的页面中,我的Equiv元标记将字符集设置为utf8
我的数据中有土耳其字符。
当我输出他们,它不显示它们应该是,但当我做 $ db-> set_charset(utf8);
,它的工作原理。 / p>
为什么我必须使用 $ db-> set_charset(utf8);
-8 encoding?
在MySQL中以UTF-8格式存储,客户端连接排序规则不是。这是为什么你必须在PHP中使用 set_charset
来连接数据库。
更新
php.ini :default_charset utf-8
.htaccess :AddDefaultCharset utf-8
My table's collation is utf8_general_ci.
My pages are encoded with UTF-8 (without BOM).
Within my pages, my Equiv meta tag sets character set to utf8
My data has Turkish characters in it.
When i output them, it's not showing them as it should be but when i do $db->set_charset("utf8");
, it works.
Why do i have to use $db->set_charset("utf8");
even though everything is utf-8 encoded?
The data is stored as UTF-8 in MySQL, but the PHP's client connection collation is not. Which is why you have to use set_charset
in PHP for the DB connection.
Update
php.ini : default_charset utf-8
.htaccess : AddDefaultCharset utf-8
这篇关于为什么我必须使用set_charset(“utf8”),即使一切都是utf-8编码? (MySQLi-PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!