今天要导出四月份的数据,可是在导出的时候出现了一个问题,在导出数据的最后出现了一堆代码,并且数据导出不完整php
而后在本地服务器测试的时候发现倒是能够正常导出的服务器
比较发现本身把本地的警告提示等级调成了(E_ALL& ~E_NOTICE & ~E_STRICT)app
而在服务器上的是(E_ALL)函数
以后调取php notice,发现错误是 iconv(): Unknown error (84)测试
很迷茫不知道是什么错误,百度一下编码
string iconv ( string $in_charset , string $out_charset , string $str )
将字符串 str 从 in_charset 转换编码到 out_charset。code
参数
in_charset:输入的字符集。
out_charset:输出的字符集。utf-8
查看官方文档文档
The output charset.
If you append the string //TRANSLIT to out_charset transliteration is activated. This means that when a character can’t be represented in the target charset, it can be approximated through one or several similarly looking characters. If you append the string //IGNORE, characters that cannot be represented in the target charset are silently discarded. Otherwise, str is cut from the first illegal character and an E_NOTICE is generated.字符串
大概的意思就是:
若是你加上 //TRANSLIT 到out_charset 的参数后面,意味着若是找不到目标编码,则程序会去找与其相近的编码。若是你加的是//IGNORE,则不会去找相近的编码,并且只要有一个字符是程序没法识别的则将会报错。
便可肯定问题方向了
iconv()函数转码的时候某个字符不能被目标字符所表示
这时候就须要iconv()函数第二个参数的//TRANSLIT、//IGNORE两个值了
因而我将代码:
$row[$key] = iconv('utf-8', 'gbk', $value);
改成:
PHP
$row[$key] = iconv('utf-8', 'gbk//TRANSLIT//IGNORE', $value);