Home > Backend Development > PHP Tutorial > What is the specific function of SET NAMES UTF8?

What is the specific function of SET NAMES UTF8?

WBOY
Release: 2016-08-04 09:20:43
Original
1791 people have browsed it

In order to prevent garbled characters, I have set up several character sets for db:

<code>        mysqli_query($db,"SET NAMES UTF8");
        mysqli_query($db,"set character_set_client=utf8");
        mysqli_query($db,"set character_set_connection=utf8");
        mysqli_query($db,"set character_set_results=utf8");</code>
Copy after login
Copy after login

But I saw an article saying this:
http://zhangxugg-163-com.iteye.com/blog/1835721

What is the specific function of SET NAMES UTF8?

According to the above description, is one SET NAMES UTF8 already equal to set character_set_client=utf8; set character_set_connection=utf8; set character_set_results=utf8; What about these three?

Let’s discuss
.`

Reply content:

In order to prevent garbled characters, I have set up several character sets for db:

<code>        mysqli_query($db,"SET NAMES UTF8");
        mysqli_query($db,"set character_set_client=utf8");
        mysqli_query($db,"set character_set_connection=utf8");
        mysqli_query($db,"set character_set_results=utf8");</code>
Copy after login
Copy after login

But I saw an article saying this:
http://zhangxugg-163-com.iteye.com/blog/1835721

What is the specific function of SET NAMES UTF8?

According to the above description, is one SET NAMES UTF8 already equal to set character_set_client=utf8; set character_set_connection=utf8; set character_set_results=utf8; What about these three?

Let’s discuss
.`

What is the specific function of SET NAMES UTF8?

<code>set NAMES utf8
show variables like "character_set_%"</code>
Copy after login

What is the specific function of SET NAMES UTF8?

The operation display is like this

As answered above, the three values ​​of character_set_client/character_set_connection/character_set_results have been changed

Yes, one command is equal to the 3 items you listed. The main thing is to ensure that the encoding is consistent and not garbled

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template