Home  >  Article  >  php教程  >  linux 下 php的 iconv()函数

linux 下 php的 iconv()函数

WBOY
WBOYOriginal
2016-06-13 10:03:441081browse

使用iconv方法进行编码转换。在windows平台下面可以正常的工作(本地环境使用的win7),但是在linux环境下面iconv总是返回false(测试环境使用的linux)。

参考phpinfo的信息,iconv模块也已经正确加载。
google一下。原来才知道,原来在linux版本下iconv这个方法还是有点下下问题的。
csdn上的一个网友给出的解决方案为:
一种方法是把iconv换成 mb_convert_encoding
另一种方法是修改iconv 的实现,从glibc 改为libiconv
搞了半天,烦躁!
有朋友碰到的话,也可以这么解决了
按照该网友提供的第一个方法,将iconv方法修改为使用mb_convert_encoding,搞定。。
多谢该网友提供的解决方案。


下载:ftp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.8.tar.gz
安装:
#cp libiconv-1.8.tar.gz /usr/local/src
#tar zxvf lib*
#./configure --prefix=/usr/local/libiconv
#make
#make install
编译php
#./configure --prefix=/usr/local/php4.3.2 --with-iconv=/usr/local/libiconv/

使用的简单例子:

echo iconv("gb2312","ISO-8859-1","我们");

Statement:
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