How to solve PHP garbled characters

Source: Internet
Author: User
This article describes several solutions to PHP garbled text. PHP garbled Problem 1. how does PHP handle uploaded CSV files? You can use the fgetcsv function: -- read a row from the file pointer and parse the CSV field, but he cannot process the Chinese characters.

PHP garbled Problem 1. how does PHP handle uploaded CSV files?

You can use the fgetcsv function: -- read a row from the file pointer and parse the CSV field, but he cannot process the Chinese characters in it. Therefore, after uploading, convert the csv to the encoding;

PHP garbled problem 2. encoding conversion;

 
  1. iconv("GB2312","UTF-8
    //IGNORE",file_get_contents($uploadfile));


Ignore indicates ignoring errors during conversion, but using another function seems better than mb_convert_encoding;

PHP garbled problem 3. Jmail may also cause garbled characters when sending emails:

If the webpage is UTF-8 encoded, you CAN $ jmail-> charset = 'utf8 ';
However, most of the inbox is GB2312. you can use mb_convert_encoding to convert the positive file;

 
  1. $ Zhengwen = 'only good mothers in the world ';
  2. $ Jmail-> Body = mb_convert _
    Encoding ($ zhennwen, 'gb2312', 'utf-8 ');

We hope that this article will help you solve the three PHP garbled problem handling skills.


Prepare how to process uploaded CSV files? You can use the fgetcsv function: -- read a row from the file pointer and parse the CSV field, but he cannot process the Chinese characters in it...

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.