PHP Tutorial: convert a string to UTF-8 Encoding

Source: Internet
Author: User
PHP cannot process strings to process data, but we must make the database encoding consistent with that of the webpage or application. Otherwise, garbled characters may occur. Therefore, before data storage or updating-when calling the data storage process, we must unify the data encoding. And a lot of web pages are based on UTF-8 encoding, we

PHP cannot process strings to process data, but we must make the database encoding consistent with that of the webpage or application. Otherwise, garbled characters may occur. Therefore, before data storage or updating-when calling the data storage process, we must unify the data encoding. And a lot of web pages are based on UTF-8 encoding, we

PHP cannot process strings to process data, but we must make the database encoding consistent with that of the webpage or application. Otherwise, garbled characters may occur. Therefore, before data storage or updating-when calling the data storage process, we must unify the data encoding. And a lot of web pages are based on UTF-8 encoding, we now look at, before the data storage, we should do how to achieve the conversion of encoding. Here, we take the conversion string encoding into the UTF-8 as an example to see how to deal with it.

Function
 ??

Here, two important functions are used. One is the mb_detect_encoding function used to obtain the encoding. PHP Tutorial: Use mb_detect_encoding to obtain the encoding of a string. Use the mb_check_encoding function to check the encoding. It is worth noting that when we store or update data, we must use the addslashes () function to process the output results !!

Statement: This article uses BY-NC-SA protocol for authorization | IT passers-
Reprinted please note

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.