时间: 2020-10-12|tag:57次围观|0 条评论

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

文章提供这款mb_detect_encoding函数是一款可以检测你使用的字符串是什么编码,然后返回字符串编码字符,下面是一个简单应用实例.

  1. function asciitog($brand
  2.  $cha=mb_detect_encoding($brand); 
  3.  if($cha=='utf-8'
  4.  { 
  5.    $brand2 = iconv($cha,"gb2312",$brand); 
  6.  } 
  7.  $cha2=mb_detect_encoding($brand2); 
  8.  if($cha2!='ascii'){ 
  9.   $brand=$brand2
  10.  } 
  11.  
  12.  return $brand//开源代码phpfensi.com

mb_detect_encoding

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

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

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《php 检测字符编码mb_detect_encoding()函数 – php函数
   

还没有人抢沙发呢~