What is the difference between the mysqli_set_charset function in mysqli and setting SETNAMES in SQL?

Source: Internet
Author: User
I used to use the SETNAMESutf8 statement to set the character set before each connection, but in mysqli There Is A mysqli_set_charset function that does this. I thought it was exactly the same as what I set myself, however, Thisisthepreferred is found in its document note... I used to use Set names utf8Statement to set the character set, but in MysqliThere is Mysqli_set_charsetThe function does this. I thought it was exactly the same as what I set myself, but in its document note, I found that

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

The two are different. What is the difference?

Reply content:

I used to useSet names utf8Statement to set the character set, but inMysqliThere isMysqli_set_charsetThe function does this. I thought it was exactly the same as what I set myself, but in its document note, I found that

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

The two are different. What is the difference?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.