JAVA、PHP、前端、APP、网站开发 - 开发技术学习

开发技术学习 » 编程开发 » php mb_detect_encoding函数,开启mb_detect_encoding,检测字符编码

php mb_detect_encoding函数,开启mb_detect_encoding,检测字符编码

此文被围观4041日期: 2013-02-02 分类 : 编程开发  标签:  ····
今天在调试博客发现出现一个错误,内容标题。 call to undefined function mb_convert_encoding in。。。 在网上找了一些解决方法,基本上都是windows下的php解决方法。 在php.ini中开启mbstring函数库:去掉extension=php_mbstring.dll前面的分号; 但是我的系统是linux所以终于找到解决方法。特此记录。 首先安装 php-mbstring库文件: yum install php-mbstring 之后,修改/etc/php.ini文件,在里面加一句 extension=mbstring.so 保存后重启httpd服务。 service httpd restart // 检测字符编码mb_detect_encoding()函数 文章提供这款mb_detect_encoding函数是一款可以检测你使用的字符串是什么编码,然后返回字符串编码字符,下面是一个简单应用实例。 [php] function asciitog($brand) { $cha=mb_detect_encoding($brand); if($cha=='utf-8') { $brand2 = iconv($cha,"gb2312",$brand); } $cha2=mb_detect_encoding($brand2); if($cha2!='ascii'){ $brand=$brand2; } return $brand; } [/php] mb_detect_encoding 语法 string mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] ) 说明 mb_detect_encoding 用来检测字符串所使用编码,并返回相对应编码字符串!

站点声明:部分内容源自互联网,为传播信息之用,如有侵权,请联系我们删除。

© Copyright 2011-2024 www.kfju.com. All Rights Reserved.
超级字帖 版权所有。蜀ICP备12031064号