分享PHP乱码问题的几种解决技巧_PHP教程

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

PHP乱码问题1、PHP 如何处理上传的CSV文件?

可以用fgetcsv函数: -- 从文件指针中读入一行并解析 CSV 字段,但他无法处理里边的中文;所以在上传后,要先把csv转一下编码;

PHP乱码问题2、编码转换;

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


ignore的意思是忽略转换时的错误; 但用另一个函数似乎更好一些mb_convert_encoding;

PHP乱码问题3、Jmail 发信时乱码也可能是这个原因:

如果网页是UTF8编码的;可以$jmail->charset = 'utf8';
但收件箱大多是GB2312的,可以把正文件用mb_convert_encoding转一下;

  1. $zhengwen = '世上只有妈妈好';
  2. $jmail->Body = mb_convert_
    encoding
    ($zhennwen, 'GB2312', 'UTF-8');
Copy after login

希望通过本文介绍的三种PHP乱码问题的处理技巧经验,能帮助大家解决问题。


www.bkjia.com true http://www.bkjia.com/PHPjc/446192.html TechArticle PHP乱码问题1、PHP 如何处理上传的CSV文件? 可以用fgetcsv函数: -- 从文件指针中读入一行并解析 CSV 字段,但他无法处理里边的中文;所以在...
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!