Home > Backend Development > PHP Tutorial > Share several solutions to PHP garbled problems_PHP Tutorial

Share several solutions to PHP garbled problems_PHP Tutorial

WBOY
Release: 2016-07-15 13:31:55
Original
1012 people have browsed it

PHP garbled problem 1. How does PHP process uploaded CSV files?

You can use the fgetcsv function: -- Read a line from the file pointer and parse the CSV field, but it cannot process the Chinese inside; so after uploading, you must first convert the CSV to encoding;

PHP garbled problem 2. Encoding conversion;

<ol class="dp-xml"><li class="alt"><span><span>iconv("GB2312","UTF-8<br>//IGNORE",file_get_contents($uploadfile)); </span></span></li></ol>
Copy after login


ignore means ignoring errors during conversion; but it seems better to use another function mb_convert_encoding;

PHP garbled problem 3. Garbled characters when sending Jmail may also be due to this reason:

If the web page is UTF8 encoded; you can $jmail->charset = 'utf8';
But most of the inboxes are GB2312, you can convert the original files with mb_convert_encoding;

<ol class="dp-xml">
<li class="alt"><span><span>$</span><span class="attribute">zhengwen</span><span> = </span><span class="attribute-value">'世上只有妈妈好'</span><span>;  </span></span></li>
<li>
<span>$jmail-</span><span class="tag">></span><span class="attribute">Body</span><span> = </span><span class="attribute-value">mb_convert_<br>encoding</span><span>($zhennwen, 'GB2312', 'UTF-8'); </span>
</li>
</ol>
Copy after login

I hope to solve the three PHP garbled problems introduced in this article Skills and experience can help everyone solve problems.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446192.htmlTechArticlePHP garbled problem 1. How does PHP process uploaded CSV files? You can use the fgetcsv function: -- Read a line from the file pointer and parse the CSV field, but it cannot process the Chinese inside; so...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template