Why do i have to use set_charset(“utf8”) even thou

2019-07-07 02:36发布

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?

1条回答
老娘就宠你
2楼-- · 2019-07-07 02:51

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

查看更多
登录 后发表回答