Heim  >  Artikel  >  Backend-Entwicklung  >  mysqli里的mysqli_set_charset函数和自己在sql里设置SET NAMES有什么不同?

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

WBOY
WBOYOriginal
2016-06-06 20:51:33921Durchsuche

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

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn