Maison  >  Article  >  développement back-end  >  mysqli里的mysqli_set_charset函数和自己在sql里设置SET NAMES有什么不同?

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

WBOY
WBOYoriginal
2016-06-06 20:51:33921parcourir

我以前一直是在每次连接之前使用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.

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

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn