PHP gets the encoded format of the string function

Source: Internet
Author: User
  1. $encode = mb_detect_encoding ($string, Array ("ASCII", ' utf-8′, "gb2312′," GBK ", ' big5′));
  2. Echo $encode;
Copy Code

So you know what encoding format it is.

In addition, if you want to transcode it, you can refer to the following code:

  1. if ($encode = = "Utf-8″) {
  2. $string = Iconv ("Utf-8″," GBK ", $string);
  3. }
Copy Code

About the format of PHP file or string encoding, involving a wide range of content, the programmer's home, later for everyone to introduce in detail. Introduce these today, hope can help everyone. You may be interested in the article: learn PHP string encoding conversion and determine whether PHP judgment string encoding is UTF8 function example PHP judgment character encoding two methods PHP automatic detection of content encoding and conversion of the code to automatically detect the encoding in the content and convert the function PHP code conversion function ( Auto-Convert character set supports array conversion) PHP change the function of the encoding Iconv

  • 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.