当前位置:编程学习 > php >>

php函数:判断字符编码的简单方法

  1. <?php
  2. function chkbm($string){
  3.     $bm = array(ASCII, GBK, UTF-8);
  4.     foreach($bm as $c){
  5.         if( $string === iconv(UTF-8, $c, iconv($c, UTF-8, $string))){//转换编码后是不是相等
  6.             return $c;
  7.         }
  8.     }
  9.     return null;
  10. }
  11. ?>

补充:Web开发 , php ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,