教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php 检测字符编码mb_detect_encoding()函数

php 检测字符编码mb_detect_encoding()函数

发布时间:2016-10-27   编辑:jiaochengji.com
教程集为您提供php 检测字符编码mb,detect,encoding()函数等资源,欢迎您收藏本站,我们将为您提供最新的php 检测字符编码mb,detect,encoding()函数资源

文章提供这款mb_detect_encoding函数是一款可以检测你使用的字符串是什么编码,然后返回字符串编码字符,下面是一个简单应用实例。
*/
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;
}

/*
mb_detect_encoding
语法

string mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] )

说明
mb_detect_encoding 用来检测字符串所使用编码,并返回相对应编码字符串!

本站原创教程转载注明来源于http://www.jiaochengji.com/phper/php.html
*/

您可能感兴趣的文章:
php 检测字符编码mb_detect_encoding()函数
php mb_detect_encoding检测字符串编码有误的问题
php获取字符串编码的函数mb_detect_encoding
php判断字符编码的二个方法
php中mb_detect_encoding检测文件编码方法[非完美]
php判断字符串编码是否为utf8的函数举例
php 自动检测内容编码并转换的代码
php获取字符串的编码格式的函数
学习php字符串编码的转换与判断
PHP批量修改静态html文件编码的例子

[关闭]
~ ~