Home  >  Article  >  Backend Development  >  mysqli里的mysqli_set_charset函数和自己在sql里设置SET NAMES有什么不同?

mysqli里的mysqli_set_charset函数和自己在sql里设置SET NAMES有什么不同?

WBOY
WBOYOriginal
2016-06-06 20:51:33919browse

我以前一直是在每次连接之前使用SET NAMES utf8语句来设定字符集,但是在mysqli里有一个mysqli_set_charset函数就是干这个的,我以为它跟我自己设定是完全一样的,但是在它的文档note里发现

This is the preferred way to change the charset. Using mysqli_query() to set it (such as SET NAMES utf8) is not recommended.

看来这两者是有所不同的,到底区别在哪里呢?

回复内容:

我以前一直是在每次连接之前使用SET NAMES utf8语句来设定字符集,但是在mysqli里有一个mysqli_set_charset函数就是干这个的,我以为它跟我自己设定是完全一样的,但是在它的文档note里发现

This is the preferred way to change the charset. Using mysqli_query() to set it (such as SET NAMES utf8) is not recommended.

看来这两者是有所不同的,到底区别在哪里呢?

Statement:
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